TF2 isolines

Hello,

I am using TF2 to draw some curves.
Here is an example:

{
    auto f2 = new TF2("f2","sin(x)*sin(y)/(x*y)",0,5,0,5);
    f2->Draw();
}

I like the red isolines, but I am loosing z-value information as compared to f2->Draw("surf1");.
Is there any way to draw the z-val in a textbox aside of each isoline ?

OR something like this with color maybe… (I am sorry I could not find any documentation about this. Forgive me if I missed something)

There is an example. see:

https://root.cern/doc/v628/ContourList_8C.html

Hello, thank you for the example. I actually already had a look at that one, but this is about TH2, right ?
My main issue is rather how to get each individual contour plot without redoing the whole drawing process.

The option LIST combined with CONT allows to retrieve the contours in a TH2. Then you have all the contours as individual graphs.

I must be missing something, but my issue is about TF2 not TH2

I do not understand where your issue is. The way it works is the following:

  1. you have a TH2F
  2. you draw it with the option CONT LIST
  3. All the contours are available à TGraphs
  4. you can draw them plus the contour level text

That’s what the example I pointed is doing.
If you start from a TF2 do:

   auto f2 = new TF2("f2","0.1+1000*((1-(x-2)*(x-2))*(1-(y-2)*(y-2)))",1,3,1,3);
   TH2F *h2 = (TH2F*)f2->GetHistogram();

Ok… I see the shortcut now. :slight_smile:

I mentioned TF2, but sorry I didn’t know about TF2::GetHistogram.
Thank you so much !

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.