Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
gr009_bent_err.py
Go to the documentation of this file.
1## \file
2## \ingroup tutorial_graphs
3## \notebook -js
4## Graph with bent error bars. Inspired from work of Olivier Couet.
5##
6## See the [TGraphBentErrors documentation](https://root.cern/doc/master/classTGraphBentErrors.html)
7##
8## exl / exh: low and high (left/right) errors in x; similar for y
9## e*d: delta, in axis units, to be added/subtracted (if >0 or <0) in x or y from
10## the data point's position to use as end point of the corresponding error
11##
12## \macro_image
13## \macro_code
14##
15## \author Alberto Ferro
16
17import ROOT
18
19c1 = ROOT.TCanvas()
20n = 10
21x = ROOT.std.vector("double")() # The equivalent is also achieveable with numpy arrays
22for i in [-0.22, 0.05, 0.25, 0.35, 0.5, 0.61, 0.7, 0.85, 0.89, 0.95]:
24y = ROOT.std.vector("double")()
25for i in [1, 2.9, 5.6, 7.4, 9, 9.6, 8.7, 6.3, 4.5, 1]:
27exl = ROOT.std.vector("double")()
28for i in [0.05, 0.1, 0.07, 0.07, 0.04, 0.05, 0.06, 0.07, 0.08, 0.05]:
30eyl = ROOT.std.vector("double")()
31for i in [0.8, 0.7, 0.6, 0.5, 0.4, 0.4, 0.5, 0.6, 0.7, 0.8]:
33exh = ROOT.std.vector("double")()
34for i in [0.02, 0.08, 0.05, 0.05, 0.03, 0.03, 0.04, 0.05, 0.06, 0.03]:
36eyh = ROOT.std.vector("double")()
37for i in [0.6, 0.5, 0.4, 0.3, 0.2, 0.2, 0.3, 0.4, 0.5, 0.6]:
39exld = ROOT.std.vector("double")()
40for i in [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]:
42eyld = ROOT.std.vector("double")()
43for i in [0.0, 0.0, 0.05, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]:
45exhd = ROOT.std.vector("double")()
46for i in [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]:
48eyhd = ROOT.std.vector("double")()
49for i in [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.05, 0.0]:
51
53 n,
54 x.data(),
55 y.data(),
56 exl.data(),
57 exh.data(),
58 eyl.data(),
59 eyh.data(),
60 exld.data(),
61 exhd.data(),
62 eyld.data(),
63 eyhd.data(),
64)
65
66gr.SetTitle("TGraphBentErrors Example")
69gr.Draw("ALP")
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.