X-Axis range and Draw("same")

Hi,

I would like to plot several histograms in the same pad using Draw(“same”). These histograms have different (but overlapping x-range). I have tried to use

histo->GetXaxis()->SetRangeUser(1.3, 2.1)

to expand the range, but it has not worked.

Ideally, it would really be nice if the “same” option could be flagged to recalculate the x and y ranges automatically. How would you recomend that I accomplish my task?

Regards,
Mark

Use the class THStack.

see examples in tutorials hstack.C, cernstaff.C, limit.C, multicolor.C

Rene

Hi Rene,

Thanks for this information, it has been very helpful, but I would like to take it further.

I have more than one object of type THStack which share some of thier histograms (i.e. I have Added a single histogram to more than one stack.) I would like to plot these two stacks in the same canvas, but the histogram that they share should have different attributes (e.g. colour). Obviously, when I change these attributes and redraw the canvas, all the versions of the histogram will have the new attributes.

Would it be possible to implement a DrawCopy method for the THStack class? Alternatively, how else would you recommend I accomplish this?

Regards,
Mark

Add a clone of your histograms to the stack, eg
THStack *s;
TH1 *h1, *h2;
s->Add(h1->Clone());
s->Add("h2->Clone());

Rene