2d Histogram from two TH1 histograms

Hello everybody!
I am new in ROOT.I have root file with TH1 histograms.I want to draw 2d histogram.i want to take one of them as x axis and one of them as y axis.But i do not know how i can do it. In generally i want to draw 2d histogram from 2 TH1 histograms.Please help me!

That does not really makes sense as 1D histogram are 1D arrays and 2D histograms 2D arrays.
Which size do you expect the 2D histogram will have ?

Thank you very much! I understood that i am wrong.I took information about my question from another person. Again thank you very much!

Hi I have similar problem.
I have a root file containing two 1D histograms with two different variables say X and Y. Now i want to draw a 2D histogram for Y vs X . How can i do that?

The question from couet is stille valide. It does not make sense to do what you want.

2D histogram is a 2D array , we can think of it as two 1D array. For example for example a 2D array contains a list of X and Y values (two columns)
if we have a list of xvalues (1D histogram) and a list of Y values(1D Histogram) can’t we combine these two to get a 2D histogram for X vs Y values. Please let me know if i am wrong.

For example, if you have a first array A1 of 5 values: {0,1, 2, 3, 4} and another one, A2, with 5 values: {10, 11, 12, 13, 14}. I guess you want to create a 2D array with 5x5 boxes. How do you combine A1 and A2 to fill the 25 boxes?

So I have some tracks(say n) , i have their y and z position in some 1D histogram , now i want to plot Y vs Z position for all those different tracks. This case makes sense but you are right as you explained in last reply that(the one u mentioned in ur reply) doesn’t make sense.

You can do what you want (plot y vs z) only if your data are stored in a TTree. If you have only the y and z information in histogram form then you cannot know what value of z corresponds to what track.

ok thanks a lot
:slightly_smiling_face: