Superimpose a histogram over another

Hello,

I would like to superimpose a histogram over another bigger one in the same canvas (see attachment). The problem is that I need to do it from the command line. I have managed to add the extra pad but I cannot draw the 2nd histogram in it. Is there some kind of a command line example for this?

Thanks,
Vivi


Hi

Maybe

root.cern.ch/root/html/tutorials … ack.C.html

could have the answers you need…

Best

Hi again,

The cd() command does not work for me. The 2nd histogram is drawn on the canvas and not in the pad. I think I must somehow activate the pad. Here is my code (the two histograms are: fPt and fEta):

TCanvas* c11 = new TCanvas("c11","c11");
c11->cd();
fEta->Draw();
TPad* p11 = new TPad("p11","p11", 0.25,0.3,0.6,0.7);
p11->cd();
fPt->Draw();
p11->Update();
c11->Update();

Try:TCanvas* c11 = new TCanvas("c11","c11"); c11->cd(); fEta->Draw(); TPad* p11 = new TPad("p11","p11", 0.25,0.3,0.6,0.7); p11->Draw(); p11->cd(); fPt->Draw(); p11->Update(); c11->Update();[quote]Is there some kind of a command line example for this?[/quote]The picture seems to indicate you somehow succeeded (at least via the gui), if this is the case, you can then use the file item File/Save/c1.C which will create a file named c1.C which contains the C++ code to reproduce the canvas.

Cheers,
Philippe.

Hi again

Try this

TCanvas* c11 = new TCanvas("c11","c11");
c11->cd();
fEta->Draw();
TPad* p11 = new TPad("p11","p11", 0.25,0.3,0.6,0.7);
p11->cd();
fPt->Draw();
p11->Update();
TH1F *htemp = (TH1F*) p11->GetPrimitive("fPt");
c11->cd();
fEta->Draw();
htemp->Draw("sames");
c11->Update();

Cheers

Thanks a lot - the c++ generated code did the trick. It finally worked by:

[code]TCanvas* c11 = new TCanvas(“c11”,“c11”);

c11->cd();
fEta->Draw();

TPad* p1 = new TPad(“p1”,“p1”, 0.25,0.3,0.6,0.7);
p1->Draw();
p1->cd();
fPt->Draw();
[/code]

Vivi