Is there a feasible way to combine multiple TH1s into a single plot similar to the TMultiGraph example shown here: (https://root.cern.ch/doc/master/classTMultiGraph.html)
My issue is the resulting plot is heavily convoluted when drawing using ‘same’. The generation of the TH1s is handled by a separate function so access to the Fill aspect is not possible. TStackedHisto is not what I am looking for, each TH1 should be independent.
Thank you kindly,
ROOT Version: 6.09/03
Platform: Ubuntu 16.04 LTS
Maybe a THStack drawn with “NOSTACK” or “NOSTACKB” is what you want.
Note also that you can easily create a TGraphErrors or a TGraph from your histogram.
By ‘create a TGraphErrors or a TGraph from histogram’ do you mean generate a TFit and the plot it with the corresponding parameters? Or is there another method that retains the bin structure of a TH1 in a TGraph?
By construction TGraph are un-binned objects.
Yes, but a single point ‘amplitude’ for each bin could be extracted (I do not know how to do this. GetBinContent() in a loop over the axis range?) then the central value of each bin and the amplitude would provide the same structure that would be lost in fitting. Is this feasible?
Yes you can do that: you define the x value of each point equal to the bin center and the y value as the bin content. But you will loose the concept of bin
Thank you, I will try this. Maybe the bin structure could be retained by storing the amplitude (y) twice. Once with x=BinCenter-BinWidth/2 and once with x=BinCenter+BinWidth/2, plotting with option “L” (no “P”) and a second function along the y=0 line, filling the area between. I think this should still look like a TH1 but be a TGraph.
Thanks for your assistance.
But to do that the best is really to use a THStack and plot it with option option NOSTACK … (as @Wile_E_Coyote said ) it is exactly what you are looking for… no need to go to graphs.
It is not quite what I need as the overlapping region of multiple semi-Gaussian distributions becomes very convoluted. My goal is to separate the different TH1s along the Z direction so they are comparable without overlapping each other.
Histograms in a thstack plotted as lines with option nostack is exactly the same as multigraph. Of course do what you want. I was just pointing to what, seems to me, is much simpler
Filling Tgraphs drawn with Draw(“L3D”) seems to be incompatible. ALF_L3Dmultigraph.pdf (27.1 KB)
ALFmultigraph.pdf (17.7 KB)
Histo0.pdf (14.2 KB)
Histo1.pdf (14.2 KB)
Histo2.pdf (14.1 KB)
Histo3.pdf (14.2 KB)
Histo4.pdf (14.2 KB)
MultiGraphL3Dtest.cpp (2.5 KB)
The usual method to shade the enclosed area using SetFillColor or SetFillColorAlpha and “F” in the draw options does not result in a filled area. I have tried adding an additional point at the end of the vectors so the first and last points are the same. Enclosing the area however this does not help.
When drawn in 3D the multigraphs are always drawn with lines.
Is there a way to override this draw function?
Ok. I do not see a way to implement this functionality with my level of ROOT proficiency. Can I submit a request for the “L3D” Draw() mode be made compatible with the other TGraph Draw() modes, specifically “F”?
You can create a Jira ticket asking for it.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.