Re: [ROOT] Plotting log axis over linear histogram

From: Olivier Couet (Olivier.Couet@cern.ch)
Date: Wed Feb 04 2004 - 10:19:16 MET


Hi Mark,

 In ROOT, when you change an attribute (here the log scale) it doesn't 
only affect (like in PAW) the subsequent drawings you may have in your 
macro. The "Draw" method doesn't "Paint" anything on the pad, it just add 
in the pad a new object to be painted later on. "Later on" means on macro 
exit when Pad->Modified() is automatically called for you. So doing 
something like:

c1->SetLogx(1)
b.Draw();
c1->SetLogx(0)

is the same as:

c1->SetLogx(0)
b.Draw();

What you should do is to create an other pad overlaying the first one, and 
turn on the log scales in that new pad. Seems to me the example given is a 
good starting point:

 http://root.cern.ch/root/roottalk/roottalk01/1552.html

Cheers,       Olivier
 

On 3 Feb 2004, Mark Messier wrote:

> Hi,
> 
> I'd like show a 2-D histogram which has been booked using a linear scale
> (which corresponds to log10() of the variable I'm interested in) using a
> log scale on a plot. Here's my try:
> 
> TH2F a("a", "a", 40,   -4,   -1, 40,   -4,   -1); // Contains my data
> TH2F b("b", "b",  1, 1e-4, 1e-1,  1, 1e-4, 1e-1); // Used for axis
> TCanvas* c1 = new TCanvas("c1","c1");
> c1->SetLogx()
> c1->SetLogy()
> b.Draw();       // To draw the axes using log format
> c1->SetLogx(0)
> c1->SetLogy(0)
> a.Draw("SAME"); // To draw the histogram, but redraws the frame!
> 
> This closely follows what I know works in PAW:
> 
> 2d 100 'a' 40 -4 -1 40 -4 -1
> opt logx
> opt logy
> null 1e-4 1e-1 1e-4 1e-1
> opt linx
> opt liny
> h/pl 100 s
> 
> I've tried a few things using TAxis but haven't hit on the right
> combination.
> 
> Any suggestions?
> 
> Thanks,
> Mark
> 

-- 
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910      
E-Mail: Olivier.Couet@cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7677155



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:05 MET