Re: TH2F & drawing curve

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 28 Nov 2007 18:33:32 +0100


So, why do you create a TH2 instead of a TH1 or better a TGraph?

Rene Brun

Nevzat Guler wrote:
> Hello,
> Actually I think there is no way for what I want to do with the
> TH2 so I am converting all my TH2 objects into TGraph. with TGraph I can
> just use Draw("L") which will draw line through the points..
> But if you want to investigate more just for curiosity, I explained
> more below:
> My data looks like ( an example )
> bin# value
> 1 23
> 2 24
> 3 26
> 4 32
> 5 27
> 6 25
> 7 23
> 8 21
> 9 19
>
> Then I define TH2F and fill it and draw it:
>
> TH2F *2D = new TH2F(rname,"",40,80.,150.,500,0.,500.);
> 2D->Fill(bin, value[bin]);
> 2D->Draw();
>
> This actually looks looks like one dimensional gaussian histogram but
> created as TH2 object. (because of the format of the data)
>
> So, my conclusion is that there is no drawing option for this that will
> simply draw line through the data points. I suppose it is because the
> format of the data is more suitable for TGraph instead of TH2..
>
> Thanks, Best regards.
>
>
> Nevzat Guler
>
> On Wed, 28 Nov 2007, Olivier Couet wrote:
>
>
>> I am not sure to really understand the kind of plot you would like. From
>> a TH2 it seems difficult to draw a 2d curve . what will be the x and y
>> coordinates of the points ?
>>
>> -----Original Message-----
>> From: Nevzat Guler [mailto:nguler_at_jlab.org]
>> Sent: Tuesday, November 27, 2007 7:35 PM
>> To: Olivier Couet
>> Cc: Root Group
>> Subject: RE: [ROOT] TH2F & drawing curve
>>
>>
>> Thanks. But I wanted 2 dimensional curve on 2 dimensional plot.
>> A simplified example:
>>
>> TH2F *2D = new TH2F(rname,"",40,80.,150.,500,0.,500.);
>> 2D->Fill(w, count[w]);
>> 2D->Draw("same");
>>
>> This looks something like a gaussian dist. But only points..
>> I want to connect these points with line, or I only want to plot it as a
>> line. The "surf" option converts it to a 3D picture..
>> Best regards,
>>
>> Nevzat Guler
>>
>> On Tue, 27 Nov 2007, Olivier Couet wrote:
>>
>>
>>> Hi,
>>>
>>> That's the option SURF.
>>>
>>> Cheers, O.Couet
>>>
>>> -----Original Message-----
>>> From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch]
>>> On Behalf Of Nevzat Guler
>>> Sent: Tuesday, November 27, 2007 4:31 AM
>>> To: Root Group
>>> Subject: [ROOT] TH2F & drawing curve
>>>
>>>
>>> Hello,
>>> Is there a drawing option for 2D histogram (TH2F) that draws
>>> curve
>>> through data points? (like the option "C" in TH1F..)
>>> I could not find any such option in the list. Basically I can convert
>>> the
>>> histogram into a TGraph object but I am looking for an easy way out..
>>> Thanks for the helps..
>>>
>>> Nevzat Guler
>>>
>>>
>>>
>>>
>>
>
>
Received on Wed Nov 28 2007 - 18:33:51 CET

This archive was generated by hypermail 2.2.0 : Wed Nov 28 2007 - 23:50:02 CET