Write 2 histos in one ps file

Hi all,

I have a small problem I cannot solve.
I do:

histo1->Draw();
histo2->Draw(“SAME”);

and now I want to write both into one ps file.
I know there are commands from TPad and TCanvas::SaveAs()
but that does not help here since I have no TPad pointer. I do not want to create a TPAd before the Draw() lines because that would mess up my code a bit …

histo1->Print(“bla.eps”)

does not help either because histo2 is missing then …

Any idea how I can do that?

Thanks
Andi

Simply instantiate a canvas before drawing your histos
TCanvas c;

Rene

Thanks, that helps already.

Unfortunately the whole situation is more complex. (I dont use h1->Draw(), but specialized method which use a canvas internaly already)

Anyway: Is there a way to prevent the

TCanvas c;

from poping up on the screen and still beeing able to write out the eps file?
Or is the an "autoclose’ TCanvas method?

I guess the following might do as well:

TCanvas* tmp = new TCanvas();
h1->Draw();
h2->Draw(“SAME”);
tmp->SaveAs(“bla.eps”);
delete tmp;

Cheers
Andi

run ROOT in batch mode
root -b

Rene

Hi,

yep that works as well.

It’s fine now.

Thanks
Andi