Open main menu

Changes

no edit summary
Under Linux installation is not difficult at all.
<texcode>
\startluacode
function test_ROOT(filename)
require("python")
pg = python.globals()
 
python.execute([[
def run(filename):
from ROOT import TCanvas, TGraph
from ROOT import gROOT
from math import sin
from array import array
 
 
gROOT.Reset()
 
c1 = TCanvas( 'c1', 'A Simple Graph Example', 200, 10, 700, 500 )
 
c1.SetFillColor( 42 )
c1.SetGrid()
 
n = 20
x, y = array( 'd' ), array( 'd' )
 
for i in range( n ):
x.append( 0.1*i )
y.append( 10*sin( x[i]+0.2 ) )
 
gr = TGraph( n, x, y )
gr.SetLineColor( 2 )
gr.SetLineWidth( 4 )
gr.SetMarkerColor( 4 )
gr.SetMarkerStyle( 21 )
gr.SetTitle( 'a simple graph' )
gr.GetXaxis().SetTitle( 'X title' )
gr.GetYaxis().SetTitle( 'Y title' )
gr.Draw( 'ACP' )
c1.Update()
c1.Print(filename)
]])
run = pg.run
run(filename)
 
end
\stopluacode
 
\starttext
\startTEXpage
\ctxlua{test_ROOT("testsin.pdf")}
\rotate[rotation=90]{\externalfigure[testsin.pdf][width=5cm]}
\stopTEXpage
\stoptext
</texcode>
[[Image:Testsin.jpg]]
= ConTeXt mkIV examples=
== ROOT ==
<texcode>
\startluacode
function test_ROOT(filename)
require("python")
pg = python.globals()
 
python.execute([[
def run(filename):
from ROOT import TCanvas, TGraph
from ROOT import gROOT
from math import sin
from array import array
 
 
gROOT.Reset()
 
c1 = TCanvas( 'c1', 'A Simple Graph Example', 200, 10, 700, 500 )
 
c1.SetFillColor( 42 )
c1.SetGrid()
 
n = 20
x, y = array( 'd' ), array( 'd' )
 
for i in range( n ):
x.append( 0.1*i )
y.append( 10*sin( x[i]+0.2 ) )
 
gr = TGraph( n, x, y )
gr.SetLineColor( 2 )
gr.SetLineWidth( 4 )
gr.SetMarkerColor( 4 )
gr.SetMarkerStyle( 21 )
gr.SetTitle( 'a simple graph' )
gr.GetXaxis().SetTitle( 'X title' )
gr.GetYaxis().SetTitle( 'Y title' )
gr.Draw( 'ACP' )
c1.Update()
c1.Print(filename)
]])
run = pg.run
run(filename)
 
end
\stopluacode
 
\starttext
\startTEXpage
\ctxlua{test_ROOT("testsin.pdf")}
\rotate[rotation=90]{\externalfigure[testsin.pdf][width=5cm]}
\stopTEXpage
\stoptext
</texcode>
[[Image:Testsin.jpg]]