Limits plot with asymmetric -/+ 1 and 2 sigma bands

Continuing the discussion from Brazil-flag plot using TGraphAsymmError:

Hello, apologies for bringing back this topic. I would like to make a Brazilian flag plot and I’m wondering how the +/- 1 and 2 sigma values should be defined.
To follow from the example given in the linked previous post, I’m wondering if, for example, -1 sigma limits should be in ex, and +1 sigma limits in ey.

Hope the question makes sense.

Thanks for your help,
Chilufya

Hi Chilufya,

Have you tried to have two graphs, with the same points but two different sets of errors along the y axis?

Best,
D

Hello @Danilo

Thanks for your reply. And I’m sorry for the noise. I figured out my issue by using TGraphAsymmErrors such that I can now pass my 1sigma values in one graph, and the 2 sigma values in another graph. Previously, I was using TGraphErrors which gives symmetric errors. Here’s a snippet of my python code in case it would be useful to someone else in future. The ROOT version used is v6-30-02.

from ROOT import TCanvas, TGraphErrors, TGraph, TGraphAsymmErrors
from ROOT import gROOT
from array import array
import math

canvas = TCanvas("c41","c41",200,10,600,400);
n = 5
#mass points                                                                            
x  = array( 'f', [800, 900, 1000, 2000, 3000])
#median limits                                                                          
y  = array( 'f', [0.14235, 0.155591, 0.172235, 0.203118, 0.254512])
ex = array( 'f', [0, 0, 0, 0, 0] )

#-1sigma limits                                                                         
ey1_minus = array( 'f', [math.sqrt(0.081054-0.058052)*0.5, math.sqrt(0.387335-0.274752)\
*0.25, math.sqrt(0.474636-0.334829)*0.25, math.sqrt(0.660109-0.471198)*0.25, math.sqrt(\
1.036419-0.736260)*0.25])

#+1sigma limits                                                                         
ey1_plus = array( 'f', [math.sqrt(-0.081054+0.114350)*0.5, math.sqrt(-0.387335+0.542341)*0.25, math.sqrt(0.662648-0.474636)*0.25, math.sqrt(0.924294-0.660109)*0.25, math.sqrt(1.463198-1.036419)*0.25])

#-2sigma:                                                                                
ey2_minus = array( 'f', [math.sqrt(0.081054-0.043290)*0.5, math.sqrt(0.387335-0.204179)*0.25, math.sqrt(0.474636-0.249315)*0.25, math.sqrt(0.660109-0.349909)*0.25, math.sqrt(1.036419-0.546009)*0.25])

#+2sigma                                                                                
ey2_plus = array( 'f', [math.sqrt(-0.081054+0.154670)*0.5, math.sqrt(-0.387335+0.733277)*0.25, math.sqrt(0.899110-0.474636)*0.25, math.sqrt(1.254989-0.660109)*0.25, math.sqrt(2.009040-1.036419)*0.25])

gr = TGraph( n, x, y )
gr.SetLineColor( 4 )
gr.SetLineWidth( 2 )
gr.SetMarkerColor( 4 )
gr.SetMarkerStyle( 20 )
gr.SetMarkerSize( 1 )

ge = TGraphAsymmErrors(n, x, y, ex, ex, ey2_minus, ey2_plus)
ge.SetFillColor(5)
ge.GetYaxis().SetRangeUser(-1.0, 1.0)
ge.GetXaxis().SetRangeUser(800, 3000)
ge.Draw("a3")

ge2 = TGraphAsymmErrors(n, x, y, ex, ex, ey1_minus, ey1_plus)
ge2.SetFillColor(3);
ge2.Draw("same3l")
#ge2.Draw("a3")                                                                         
gr.Draw( 'SameLP' )
canvas.SaveAs("limits.pdf")

Regards,
Chilufya

1 Like

Thanks for the code and positive attitude, Chilufya!

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