line = ROOT.TLine(start_x, start_y, end_x, end_y)
line.Draw()
・長方形を描く
box = ROOT.TBox(start_x, start_y, end_x, end_y)
box.Draw("SAME")
・円を描く
arc = ROOT.TArc(center_x, center_y, radius)
arc.Draw("SAME")
・楕円を描く
ell = ROOT.TEllipse( center_x, center_y, radius_x, radius_y)
ell.Draw("SAME")
・マーカーを描く
mark = ROOT.TMarker( x, y, 20)
mark.Draw("SAME")
・文字を入れる
text = ROOT.TText( start_x, start_y, "This is a pen." )
text.Draw("SAME")
#/bin/usr/env python
import sys, os
import ROOT
if __name__=='__main__':
graph = ROOT.TGraph()
for x in range(10) :
np = graph.GetN()
graph.SetPoint(np, x, x)
cv = ROOT.TCanvas("cv", "Graphics Example", 200, 10, 700, 500)
graph.SetLineWidth(3)
graph.SetLineColor(1)
graph.SetLineStyle(1)
graph.Draw("APC")
line = ROOT.TLine( 1, 3, 1, 8)
line.SetLineWidth(3)
line.SetLineColor(2)
line.SetLineStyle(2)
line.Draw("SAME")
box = ROOT.TBox( 3, 1, 5, 2)
box.SetFillColor(3)
box.Draw("SAME")
arc = ROOT.TArc( 5, 6, 2)
arc.SetLineWidth(3)
arc.SetLineColor(4)
arc.SetLineStyle(1)
arc.Draw("SAME")
ell = ROOT.TEllipse( 8, 3, 1.3, 2)
ell.SetLineWidth(3)
ell.SetLineColor(6)
ell.SetLineStyle(1)
ell.Draw("SAME")
mark = ROOT.TMarker( 2, 3, 20 )
mark.Draw("SAME")
text = ROOT.TText( 3, 9, "This is a pen." )
text.Draw("SAME")
cv.Update()
# export
cv.Print("graphics.png")
0 件のコメント:
コメントを投稿