Save subcanvas (or pad) in divided plots

i am trying to plot two graphs on the same canvas (canvas.Divide and using TPad)
here is my code in jupyter notebook.

c2 = TCanvas("c2","c2",1600,600)
c2.SetFillColor(3)
# c2.Divide(2,1)
pad1 = TPad("pad1","This is pad1",0,0,0.5,1);
pad1.Draw()
pad1.cd()
gr1.Draw("AP")
gr2.Draw("same P")

legend = TLegend(*legend1,"")
legend.SetFillColor(0)
legend.AddEntry(gr1,labels[0],"p") 
legend.AddEntry(gr2,labels[1],"p")
legend.DrawClone("Same")
# pad1.Draw()

c2.cd()
pad2 = TPad("pad2","This is pad2",0.5,0,1,1);
pad2.Draw()
pad2.cd()
gr3.Draw("AP")
gr4.Draw("same P")

legend = TLegend(*legend2,"")
legend.SetFillColor(0)
legend.AddEntry(gr3,labels[0],"p") 
legend.AddEntry(gr4,labels[1],"p")
legend.DrawClone("Same")
# pad2.Draw()

# c2.cd()

c2.Draw()

What i want is to draw a 2–in-1 plots, and a ability to save individual plots after the c2.Draw() (but i always get empty for the 2nd plot), when I

pad1.Print("pad1.png")
pad2.Print("pad2.png")

Any idea ?

*ROOT Version:* 6.26.00 (conda_forge)
*Platform:* ubuntu20.04
*Compiler:* gcc9
___

Only the entire canvas can be printed/saved, not individual pads.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.