Error Bars Graph Root
Contents |
To see the output of error bars graph excel this macro, click begin_html here. end_html //Author: Rene
How To Do Error Bars On A Graph
Brun TCanvas *c1 = new TCanvas("c1","gerrors2",200,10,700,500); c1->SetFillColor(42); c1->SetGrid(); // draw a frame to define the range how to put error bars on a graph TH1F *hr = c1->DrawFrame(-0.4,0,1.2,12); hr->SetXTitle("X title"); hr->SetYTitle("Y title"); c1->GetFrame()->SetFillColor(21); c1->GetFrame()->SetBorderSize(12); // create first graph const Int_t n1 = 10; Double_t x1[] = {-0.22, 0.05, 0.25, 0.35, 0.5, 0.61,0.7,0.85,0.89,0.95}; Double_t y1[] = how to calculate error bars on a graph {1,2.9,5.6,7.4,9,9.6,8.7,6.3,4.5,1}; Double_t ex1[] = {.05,.1,.07,.07,.04,.05,.06,.07,.08,.05}; Double_t ey1[] = {.8,.7,.6,.5,.4,.4,.5,.6,.7,.8}; TGraphErrors *gr1 = new TGraphErrors(n1,x1,y1,ex1,ey1); gr1->SetMarkerColor(kBlue); gr1->SetMarkerStyle(21); gr1->Draw("LP"); // create second graph const Int_t n2 = 10; Float_t x2[] = {-0.28, 0.005, 0.19, 0.29, 0.45, 0.56,0.65,0.80,0.90,1.01}; Float_t y2[] = {0.82,3.86,7,9,10,10.55,9.64,7.26,5.42,2}; Float_t ex2[] = {.04,.12,.08,.06,.05,.04,.07,.06,.08,.04}; Float_t ey2[] = {.6,.8,.7,.4,.3,.3,.4,.5,.6,.7}; TGraphErrors *gr2 = new TGraphErrors(n2,x2,y2,ex2,ey2); gr2->SetMarkerColor(kRed); gr2->SetMarkerStyle(20); gr2->Draw("LP"); } gerrors2.C:1gerrors2.C:2gerrors2.C:3gerrors2.C:4gerrors2.C:5gerrors2.C:6gerrors2.C:7gerrors2.C:8gerrors2.C:9gerrors2.C:10gerrors2.C:11gerrors2.C:12gerrors2.C:13gerrors2.C:14gerrors2.C:15gerrors2.C:16gerrors2.C:17gerrors2.C:18gerrors2.C:19gerrors2.C:20gerrors2.C:21gerrors2.C:22gerrors2.C:23gerrors2.C:24gerrors2.C:25gerrors2.C:26gerrors2.C:27gerrors2.C:28gerrors2.C:29gerrors2.C:30gerrors2.C:31gerrors2.C:32gerrors2.C:33gerrors2.C:34gerrors2.C:35gerrors2.C:36gerrors2.C:37gerrors2.C:38gerrors2.C:39 » Last changed: 2015-09-08 00:33 » Last generated: 2015-09-08 00:33 This page has been automatically generated. For comments or suggestions regarding the documentation or ROOT in general please send a mail to ROOT support.
simple line Discuss installing and running ROOT here. Please post bug reports in Jira. Moderator: rootdev Post Reply Search Advanced search First unread post • 5 posts • Page 1
How To Draw Error Bars On A Graph
of 1 tweety84 Posts: 27 Joined: Fri Nov 21, 2008 11:34 Location: Naples, y error bars Italy Plotting a TH1F with error bars and simple line Quote Unread postby tweety84 » Mon Dec 19, 2011 11:14
How To Insert Error Bars In Excel Mac
Hi Rooters,I have a very simple and, probably, stupid question.I have a TH1F object, with error bars for every contents. I want to plot the markers with the error bars and also a https://root.cern.ch/root/html/tutorials/graphs/gerrors2.C.html simple line to join them. I've tried to do it with the Editor or with "histo->Draw("l*") " without success. Why??Thanks.Tina Top Pepe Le Pew Posts: 2138 Joined: Sat Oct 17, 2009 15:00 Contact: Contact Pepe Le Pew Website Re: Plotting a TH1F with error bars and simple line Quote Unread postby Pepe Le Pew » Mon Dec 19, 2011 11:39 See options "E", "E0", ..., "E6" and https://root.cern.ch/phpBB3/viewtopic.php?t=13883 "X0" in the "Options supported for 1D histograms" and in "The error bars options" paragraphs here: http://root.cern.ch/root/html/THistPainter.html Top tweety84 Posts: 27 Joined: Fri Nov 21, 2008 11:34 Location: Naples, Italy Re: Plotting a TH1F with error bars and simple line Quote Unread postby tweety84 » Mon Dec 19, 2011 13:18 Thanks for the answer. I know the options but the problem is when I try to combine them together.For example, "h->Draw("e1c")" doesn't produce the effect I desire, i.e. a TH1F with errror bars and a curve between bins. Thanks.Tina Top Pepe Le Pew Posts: 2138 Joined: Sat Oct 17, 2009 15:00 Contact: Contact Pepe Le Pew Website Re: Plotting a TH1F with error bars and simple line Quote Unread postby Pepe Le Pew » Mon Dec 19, 2011 13:25 A brutal fix:h->Draw("E1");h->Draw("C SAME"); Top tweety84 Posts: 27 Joined: Fri Nov 21, 2008 11:34 Location: Naples, Italy Re: Plotting a TH1F with error bars and simple line Quote Unread postby tweety84 » Mon Dec 19, 2011 13:29 I've already solved in this way... but it is not satisfying to me. Thanks.Tina Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by
three graphs with an exclusion zone. 4. exclusiongraph2.C Draw several graphs with an exclusion zones. 5. gerrors.C Draw a graph with error bars 6. gerrors2.C https://root.cern.ch/root/htmldoc/tutorials/graphs/index.html Draw two graphs with error bars 7. graph.C Draw a simple graph 8. graph2derrorsfit.C Create, Draw and fit a TGraph2DErrors 9. graphApply.C A macro to demonstrate the functionality of TGraphX::Apply() method 10. graphpolar.C Create and draw a polar graph 11. graphpolar2.C Create and draw a polar graph with PI axis 12. graphpolar3.C error bars Create and draw a polar graph with PI axis using a TF1 13. graphstruct.C Draw a simple graph structure. 14. graphtext.C Draw a graph with text attached to each point. 15. gtime.C example of TGraphTime 16. gtime2.C example of TGraphTime showing how the class could be used to visualize 17. labels1.C Setting alphanumeric error bars on labels in a 1-d histogram 18. labels2.C Setting alphanumeric labels 19. motorcycle.C Macro to test scatterplot smoothers: ksmooth, lowess, supsmu 20. multigraph.C Create and Draw a TMultiGraph 21. multipalette.C Draw color plots using different color palettes. 22. seism.C strip chart example 23. splines_test.C examples of use of the spline classes 24. surfaces.C Draw 2-Dim functions 25. timeonaxis.C This macro illustrates the use of the time mode on the axis 26. timeonaxis2.C Define the time offset as 2003, January 1st 27. timeonaxis3.C This example compares what the system time function gmtime and localtime give 28. waves.C Hint: Spherical waves 29. zdemo.C This macro is an example of graphs in log scales with annotations. 30. zones.C example of script showing how to divide a canvas » Last changed: 2015-09-08 00:33 » Last generated: 2015-09-08 00:33 This page has been automatically generated. For comments or suggestions regarding the documentation or ROOT in general please send a mail to ROOT support.
be down. Please try the request again. Your cache administrator is webmaster. Generated Mon, 10 Oct 2016 14:40:47 GMT by s_wx1127 (squid/3.5.20)