I’d like to fill the area between a TF1 in specific axes ranges. From the example attached, I’d like to fill the area under the red-curve in the range 0<x<40 and 0<y<200.
Any suggestion how to achieve this ?
Thanks in advance
fa.C (445 Bytes)
TF1* f1Range = (TF1*)f1->Clone("f1Range");
might help? I.e. create a clone of the function, reduce its range, and draw that with fill style.
thanks a lot for the suggestion. Yes, that works for the x-axis, but what about the y-range ? In the example, I’d just like the area underneath the curve and the straight-line y=k (k=200 in this case) to be filled.
Not sure if there’s a way to redefine my function to be something like (a,b,k being constants):
- if 0 < x <= a: y(x)=k
- if x >a: y(x) = b/x
Here is a macro doing what you requested: fa2.C (630 Bytes)
Indeed… I should have thought about that way. Thanks for the simplicity Olivier !
Sergio also not the use of “DrawFrame” in the macro I sent. It is "the way’ to define an empty frame with axis. The way you did it with an empty 2D histogram also works but it is heavier…
Yes, indeed, that’s an interesting option for quick plots. I use the empty 2D histo to define the style (axes titles, fonts, sizes, etc.); for the example I posted at the beginning I just removed everything related to style… I would think using the “DrawFrame” and modifying the TH1F it gives access to would be equivalent at the end ? The other option is to use a TStyle, which I also have but just use from time to time and varies from project to project…
DrawFrame returns a TH1F so you can apply all the setting you need on it.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.