そんなときはこれを使うべし。
cv.Divide( 1, 2 )
- #/bin/usr/env python
- import sys, math
- import ROOT
- if __name__=='__main__':
- # set graph1 style
- graph1 = ROOT.TGraph()
- graph1.SetLineWidth(2)
- graph1.SetLineColor(4)
- graph1.SetLineStyle(1)
- # set graph2 style
- graph2 = ROOT.TGraph()
- graph2.SetLineWidth(2)
- graph2.SetLineColor(3)
- graph2.SetLineStyle(1)
- # set title
- graph1.SetTitle("Graph Test 2 top")
- graph2.SetTitle("Graph Test 2 bottom")
- # set data point
- for x in range(10) :
- np = graph1.GetN()
- graph1.SetPoint(np, x, x**2)
- graph2.SetPoint(np, x, x)
- # open canvas
- cv = ROOT.TCanvas("cv", "Graph Test", 800, 800)
- # divide canvas to two
- cv.Divide(1,2)
- # top plot
- pad = cv.cd(1)
- pad.SetGridx(1)
- pad.SetGridy(1)
- # plot to top pannel
- graph1.Draw("APC")
- # set X axise of graph1
- axisY = graph1.GetYaxis()
- axisY.SetTitle("x**2")
- # bottom plot
- pad = cv.cd(2)
- pad.SetGridx(1)
- pad.SetGridy(1)
- # plot to bottom pannel
- graph2.Draw("APC")
- # set Y axise of graph1
- axisY = graph2.GetYaxis()
- axisY.SetTitle("x")
- # set X axis
- axisX = graph2.GetXaxis()
- axisX.SetTitle("x")
- # export
- cv.Print("graphtest2.png")

0 件のコメント:
コメントを投稿