Superimposing histograms/graphs with different LOG scales

Hi there,

I’d like to superimpose two TGraphs with different y log scales like in “dEdx_excel.png”.
The method given in the manual with the scale method does not seem appropriate because of the y log scale.
For the time being I’m stuck with my “dEdx_root.png”.
How should I proceed ?

Also, is there a way to rotate a TGAxis ?
For TAxis, one can use RotateTitle().

Thanks in advance,
Z




see tutorials
$ROOTSYS/tutorials/hist/twoscales.C
$ROOTSYS/tutorials/graphics/gaxis.C

Rene

Thanks René for your fast answer.
These examples are the same as in the manual.
The scale method does not work in log scale since it makes the plot go up or down, whereas it would need to be “compressed”.
I still have no idea about how to rotate a TGaxis.
Thanks, M

TGaxis is a graphics primitive drawing an axis in the 2D plane. The TGaxis constructor has four parameters (among others) defining the axis position (1st point and 2nd point). Therefore the axis can be positionned anywhere there is not need for “rotation”.

Sorry, I was talking about the title attached to a TGaxis. :unamused:

TGaxis *axis = new TGaxis(xmax,ymin,xmax,ymax,wmin,wmax,510,"+G") ; axis->SetTitle("Projected Range [#mum]") ; axis->CenterTitle() ; //axis->RotateTitle() ; // ??? How to rotate it ?
For a TAxis, one just needs to use RotateTitle()

myHistogram->GetXaxis()->RotateTitle() ; I haven’t found anything similar for TGaxis.
Thanks, M

PS: Is my problem about the superimpostition of graphs/histos with different y-logscales clear enough ?

I made an example with two graphs and two log scales:

{             
   TCanvas *c1 = new TCanvas("c1","c1",200,10,700,500);

   TPad *pad1 = new TPad("pad1","",0,0,1,1);
   TPad *pad2 = new TPad("pad2","",0,0,1,1);
   pad2->SetFillStyle(0);   
   pad2->SetFrameFillStyle(4000);   
   pad2->SetFrameFillColor(0); 

   pad1->SetLogy();  
   pad2->SetLogy();  


   const Int_t n = 20;
   Double_t x[n], y1[n], y2[n];
   for (Int_t i=0;i<n;i++) {
     x[i] = i*0.1+5;
     y1[i] = 100000*sin(x[i]+0.2);
     y2[i] = 100000*cos(x[i]+0.2);  
   }

   gr1 = new TGraph(n,x,y1);
   gr1->SetMarkerStyle(21);
   gr2 = new TGraph(n,x,y2);
   gr2->SetMarkerStyle(20);


   pad1->Draw();
   pad1->cd();
   gr1->Draw("APL");

   pad2->Draw();
   pad2->cd();
   gr2->Draw("APL Y+");  
}

Cheers ! :smiley: