# Plotting dx error bars intead of dy error bars

**URL:** <https://root-forum.cern.ch/t/plotting-dx-error-bars-intead-of-dy-error-bars/38164>\
**Category:** Newbie\
**Created:** [February 27, 2020, 10:13am UTC](https://root-forum.cern.ch/t/plotting-dx-error-bars-intead-of-dy-error-bars/38164 "2020-02-27T10:13:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luiz\_iniciante](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/b9e5f3/32.png) [@luiz\_iniciante](https://root-forum.cern.ch/u/luiz_iniciante)\
**Post date:** [February 27, 2020, 10:13am UTC](https://root-forum.cern.ch/t/plotting-dx-error-bars-intead-of-dy-error-bars/38164/1 "2020-02-27T10:13:18Z")

</div>

Dear Colleagues,  
Thanks for all the previous questions. This one relates to how to plot an n-tuple with error bars. I borrowed from this earlier [post](https://root-forum.cern.ch/t/how-to-plot-tgrapherrors-from-a-tree/9233/5) to write the attached code. The key lines are these:

```
     Long64_t N = ndepth_dose_4MVV_all_8cm->Draw("B:RMD_sub:RMD_sub_error","","goff"); 
     TGraphErrors *gr1 = new TGraphErrors (N,ndepth_dose_4MVV_all_8cm->GetV1(),ndepth_dose_4MVV_all_8cm->GetV2(),ndepth_dose_4MVV_all_8cm->GetV3()); 

```

The problem is that it is giving me error bars on ‘dx’ when I would like error bars ‘dy’. I think it should be easy to correct, though I can’t quite see the solution myself. Any help would be appreciated.

Regards,  
RL[dedao\_8cm\_error1.C](https://root-forum.cern.ch/uploads/short-url/wLhGmmHP4LCVGNNYis8Ic8c8rKo.C) (2.3 KB) [Varian\_4MV\_Total\_8cm.root](https://root-forum.cern.ch/uploads/short-url/4fFhuIU5wogLNsA9TKi9qblBZnG.root) (16.5 KB)

---

<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:** [February 27, 2020, 10:30am UTC](https://root-forum.cern.ch/t/plotting-dx-error-bars-intead-of-dy-error-bars/38164/2 "2020-02-27T10:30:28Z")

</div>

```cpp
ndepth_dose_4MVV_all_8cm->SetEstimate(-1);
Long64_t N = ndepth_dose_4MVV_all_8cm->Draw("B:RMD_sub:RMD_sub_error", "", "goff"); 
TGraphErrors *gr1 = new TGraphErrors(N, ndepth_dose_4MVV_all_8cm->GetV1(), ndepth_dose_4MVV_all_8cm->GetV2(), ((Double_t*)0), ndepth_dose_4MVV_all_8cm->GetV3()); 

```

---

<div class="post-metadata">

**Author:** ![luiz\_iniciante](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/b9e5f3/32.png) [@luiz\_iniciante](https://root-forum.cern.ch/u/luiz_iniciante)\
**Post date:** [February 27, 2020, 11:52am UTC](https://root-forum.cern.ch/t/plotting-dx-error-bars-intead-of-dy-error-bars/38164/5 "2020-02-27T11:52:16Z")

</div>

Thanks @Wile_E_Coyote, your code worked.
