Greetings, rooters!
I encountered a problem while trying to plot two 1D histograms with different binning, binwidth, and overlapping X-ranges (one is 2.4 - 3.0 MeV and the other is 2.7 - 3.4 MeV) on one Canvas (to show two graphs on one picture). What I tried is:
“same” option draws two histograms using only X-range of the first histo, when I want to see the whole range.
“nostack” option is not a solution either because it works the same way as “same” option.
I didn’t succeed in finding any example on root tutorials which could help me solve this problem.
Maybe, some of you have faced the same issue. I’d be very happy to have any help.
“If option “nostack” is specified the histograms are not drawn on top of each other but as they would if drawn using the option “same”.” I have already tried this. “nostack” option works the same way as “same” option, so it will not show me the whole range, but only the range of the first histogram.
Set the range of both histograms to be equal, in this case you have to change also the number of bins of your histograms to have the bin width that you desire.
I don’t want to set equal ranges. I want to see two histograms each having its range to show the whole picture.
h->GetXaxis()->SetRangeUser(2.4,3.4) will not help in this case. If my first histogram’s X-range is 2.4 -3.0, setting (2.4, 3.4) X axis range will still show only (2.4,3.0) range part, because SetRangeUser(lower,upper) method computes the closest bin to upper and lower limits in histogram that I set.
Ok,
you can create a new histogram h3 with range from 2.4 to 3.4 also with just one bin, don’t fill it and then h3 should be the first histogram you draw, then superimpose the others two histogram.
For sure you should adjust the y-axis after you plotted everything, but in the end will work.