Good morning,
I’m trying to get a plot like the attached one. So far I tried to use 2 TPads using SetTopMargin() and SetBottomMargin(), but I still get a blank space between the two pads, i.e. between the upper and the lower plots.
Might you suggest a better way?
Thanks a lot, and have a nice day,
Ric.
couet
September 14, 2011, 12:49pm
2
{
TCanvas *c = new TCanvas("c","c");
c->Draw();
TPad *c_1 = new TPad("c_1", "c_1",0.1,0.3,0.9,0.9);
c_1->SetBottomMargin(0.0);
c_1->Draw();
c_1->cd();
c_1->DrawFrame(0.,0.,1.,1.);
c->cd();
c_2 = new TPad("c_2", "c_2",0.1,0.1,0.9,0.3);
c_2->SetTopMargin(0.0);
c_2->Draw();
c_2->cd();
c_2->DrawFrame(0.,0.,1.,1.);
}
It’s perfect!!
Thanks a lot for your help!!
Ric.
Another question, sorry.
When I plot a histo on the lower pad, if I increase the x-axis title font, then the x-axis title goes “outside” the canvas.
Interactively I solve this by resizing the lower frame up with the mouse, and in this way the x-axis title “appear” again.
But how can I do programatically? I tried with SetBottomMargin() and setting different limits when I create the lower pad, but without success.
Which is the method to resize the frame inside a pad?
Thanks a lot again for your kind help,
Ric.
couet
September 14, 2011, 3:35pm
5
save the plot you got via interactive editing into a .C file (File/SavesAs) and look at the command doing that.
copy/paste it in your code