Baloo
September 26, 2017, 11:52am
1
Hi, I am having an issue when plotting together two graphs with different scales.
I followed the tutorial transpad.C and it works fine apart from a detail: in the end I get the ticks and labels of the right Y axis (with a different scale) also on the left side of the pad. This superimposes with the ticks of the first graph Y axis and overall is not readable.
Could please give some advice?
Thank you!
couet
September 26, 2017, 12:40pm
2
I guess you modified the original macro. Can you post you version ?
Also note that the options X+ and Y+ may be used too:
{
TCanvas *c1 = new TCanvas("c1","c1",600,600);
TPad *pad1 = new TPad("pad1","",0,0,1,1);
TPad *pad2 = new TPad("pad2","",0,0,1,1);
pad2->SetFillStyle(4000); //will be transparent
pad2->SetFrameFillStyle(0);
TH2F *h1 = new TH2F("h1","h1",40,-4,4,40,-4,4);
TH2F *h2 = new TH2F("h2"," ",40,-40,40,40,-40,40);
Double_t a,b;
for (Int_t i=0;i<5000;i++) {
gRandom->Rannor(a,b);
h1->Fill(a-1.5,b-1.5);
h2->Fill(10*a+1.5,10*b+1.5);
}
pad1->Draw();
pad1->cd();
h1->Draw("");
pad2->Draw();
pad2->cd();
h2->SetMarkerColor(kRed);
h2->Draw("X+Y+");
}
Baloo
September 26, 2017, 1:58pm
3
Thank you, for some reason I was using some code where I also included the use of additional TFrames.
Now it’s working fine, thank you again.
Regards
ksmith
September 27, 2017, 1:39pm
4
Another example of using the Y+ from last month (in python):
An alternative using the "Y+" option (no frames or extra axes needed):
from ROOT import TCanvas, TGraph, TPad
name_file="p.txt"
# create first graph
gr = TGraph( name_file ,"%lg %lg" )
gr.SetLineColor(2)
gr.SetMarkerStyle(8)
gr.SetMarkerColor(2)
# create second graph
gr2 = TGraph( name_file ,"%lg %*s %lg" )
gr2.SetLineColor(3)
gr2.SetMarkerStyle(21)
gr2.SetMarkerColor(3)
c1 = TCanvas("c1","c1",600,600)
c1.cd()
gr.Draw("ALP")
overlay = TPad("overlay","overlay",0,0,1,1)
overlay.SetFrameFillS…
system
Closed
October 11, 2017, 1:39pm
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.