I have these two plots that I would like to overlay on top of each other. But, some how I am unable to. Here is a pdf of the plots:
overlayingPlots.pdf (154.8 KB)
What I want is for the ProfileY plot to be superimposed onto the TH2D plot. Here is my attempt:
TProfile* histo2ProfY1 = cloneHistogram2->ProfileY("histo2ProfY1", 0, -1, "[cut1]");
But that doesn’t seem to work, and from the searching around I have done, it seems like it is a problem related to the fact that I am using TProfileY and not TProfileX.
I also don’t really get the solution provided on the following thread from 2011, but there might be a more robust solution by now for this problem:
I’d like to superimpose on a TH2F the result of TH2F::ProfileY(). Since the TProfile x axis is the TH2F y axis, TProfile::Draw(“same”) does not work. What is the easiest way to achieve that?
Thanks and ciao
Can someone please help me with this? Thank you very much!
The plots do have very different axis ranges they will not overlay properly. Can you post the plot you get ?
I actually don’t end up being able to get a plot with the way I approach it. It only shows the 2D plot with no 1D overlay.
One point is that, as couet said, in your TProfile the scales of x-y don’t match the 2D plot, so even if you could do “same”, the second plot wouldn’t show --in fact, x and y are swapped, so you may want to swap them back if you want them to represent the same.
Anyway maybe you can try sometihng like this (create a second Pad on top of the first one and draw the second plot there):
I am trying to plot two graphs (TGraph, NOT histograms) with different scales on the same canvas. I know there is an example in user guide which demostrates how to plot two histograms with different scales on the canvas. Yes, I could transfer TGraph to TH1 and then plot them together. I am wondering if I can do that for 2 graphs. But for TGraph , no method like Scale() in TH1. Any body could give me hints?