# Drawing a TGraphAsymmErrors

**URL:** <https://root-forum.cern.ch/t/drawing-a-tgraphasymmerrors/14205>\
**Category:** ROOT\
**Created:** [April 26, 2012, 9:40pm UTC](https://root-forum.cern.ch/t/drawing-a-tgraphasymmerrors/14205 "2012-04-26T21:40:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew1](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/9de053/32.png) [@Andrew1](https://root-forum.cern.ch/u/Andrew1)\
**Post date:** [April 26, 2012, 9:40pm UTC](https://root-forum.cern.ch/t/drawing-a-tgraphasymmerrors/14205/1 "2012-04-26T21:40:37Z")

</div>

Hi,

I am trying to Draw(“AP”); a TGraphAsymmErrors \* with an x axis range of 0 to 1. I use SetRangeUser(0.0,1.0), but the resulting figure has an axis from 0.0 to 0.45 or so. Does anyone know how to force the TGraphAsymmErrors to draw itself from 0 to 1?

Thanks.

Andrew

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [April 26, 2012, 10:16pm UTC](https://root-forum.cern.ch/t/drawing-a-tgraphasymmerrors/14205/2 "2012-04-26T22:16:01Z")

</div>

MyGraph-\>GetXaxis()-\>SetLimits(xmin, xmax);  
MyGraph-\>GetHistogram()-\>SetMinimum(ymin);  
MyGraph-\>GetHistogram()-\>SetMaximum(ymax);

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [April 27, 2012, 8:53am UTC](https://root-forum.cern.ch/t/drawing-a-tgraphasymmerrors/14205/3 "2012-04-27T08:53:37Z")

</div>

[root.cern.ch/drupal/content/how-set-ranges-axis](http://root.cern.ch/drupal/content/how-set-ranges-axis)

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [April 30, 2012, 11:49am UTC](https://root-forum.cern.ch/t/drawing-a-tgraphasymmerrors/14205/4 "2012-04-30T11:49:48Z")

</div>

Well, maybe I’d like to ask a strange question.  
Actually, “MyGraph-\>GetXaxis()-\>SetLimits(xmin, xmax);” is just a shortcut for “MyGraph-\>GetHistogram()-\>GetXaxis()-\>SetLimits(xmin, xmax);”.  
However, there is a non-negligible difference between “MyGraph-\>SetM[in|ax]imum(ym[in|ax]);” and “MyGraph-\>GetHistogram()-\>SetM[in|ax]imum(ym[in|ax]);”.  
And that difference exists not only for TGraph related classes but also for TF1, for example (well, maybe for more, but I didn’t trace it that much).  
So, the question is … when should one use which method and why?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [August 13, 2014, 12:04pm UTC](https://root-forum.cern.ch/t/drawing-a-tgraphasymmerrors/14205/5 "2014-08-13T12:04:11Z")

</div>

> [@](#):
>
> However, there is a non-negligible difference between “MyGraph-\>SetM[in|ax]imum(ym[in|ax]);” and “MyGraph-\>GetHistogram()-\>SetM[in|ax]imum(ym[in|ax]);”.

it should not be. TGraph::SetMinimum() code is:

```auto
// ______________________________________________________________________________
void TGraph::SetMinimum(Double_t minimum)
{
   // Set the minimum of the graph.

   fMinimum = minimum;
   GetHistogram()->SetMinimum(minimum);
}
```

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [August 13, 2014, 4:30pm UTC](https://root-forum.cern.ch/t/drawing-a-tgraphasymmerrors/14205/6 "2014-08-13T16:30:18Z")

</div>

Yes, the differences are related to lines in form:  
fMinimum = minimum; // [TGraph|TF1]::SetMinimum(Double\_t minimum)  
fMaximum = maximum; // [TGraph|TF1]::SetMaximum(Double\_t maximum)  
which are executed when one calls “[TGraph|TF1]::SetM[in|ax]imum(Double\_t m[in|ax]imum)”, but which are NOT executed when one uses “[TGraph|TF1]::GetHistogram()-\>SetM[in|ax]imum(Double\_t m[in|ax]imum);”.  
It is not really obvious (nor described anywhere) what side effects these lines may cause.  
Additionally, in cases like TF1, if “fHistogram” does not exist, the call to “TF1::GetHistogram()-\>SetM[in|ax]imum” will create and paint it, but a direct call to “TF1::SetM[in|ax]imum” will NOT care at all about the “fHistogram” (if it doesn’t exist).  
So, I think a good description when one should call one method and when the other one would be nice (including a description of any possible “side effects”).
