# TMultigraph not drawing all data

**URL:** <https://root-forum.cern.ch/t/tmultigraph-not-drawing-all-data/41556>\
**Category:** Newbie\
**Created:** [September 23, 2020, 10:48am UTC](https://root-forum.cern.ch/t/tmultigraph-not-drawing-all-data/41556 "2020-09-23T10:48:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![AleCalamida](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@AleCalamida](https://root-forum.cern.ch/u/AleCalamida)\
**Post date:** [September 23, 2020, 10:48am UTC](https://root-forum.cern.ch/t/tmultigraph-not-drawing-all-data/41556/1 "2020-09-23T10:48:10Z")

</div>

Dear all,

I have a problemi with the TMultigraph() funcition. I have to plot a large number of data in my graphs. The strange things is that when I use the TGraph() the plot are drawn fine without any errors. Instead, when I have to merge together the MultiGraph does not plot all the data.

The range of the data goes from 10^-3 to 5 and it plot only from 10^-3 to 10^-1. If I delete a big portion of data, focussing only on the peak of the function, everything return fine and the plot is drawn normally.

How this can be possible, where is the error?

I tried every solution to modify the range of the axis but with no avail.

I attached the data and the macro on this message. To run it you have to change only the path of the files.[Graph\_Coherent\_Detect.C](https://root-forum.cern.ch/uploads/short-url/mhYGOHq86meBvkDkxYTqsFPIiI6.C) (4.3 KB) [Detect\_0\_Alp\_Trig.txt](https://root-forum.cern.ch/uploads/short-url/ndYFRDR6gEvSezbs3JBWumy1vyO.txt) (31.7 KB) [Detect\_0\_Alp\_No\_Trig.txt](https://root-forum.cern.ch/uploads/short-url/aOas0ofZcIYiPGYCyr2KSRXn1e7.txt) (45.0 KB)

Best regards and thank you for your time, Alessandro Calamida.

* * *

_ROOT Version:_ 6.14  
_Platform:_ ubuntu 20.4  
_Compiler:_ gcc 9.3

* * *

---

<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:** [September 23, 2020, 11:27am UTC](https://root-forum.cern.ch/t/tmultigraph-not-drawing-all-data/41556/2 "2020-09-23T11:27:18Z")

</div>

I 'll look

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [September 23, 2020, 11:34am UTC](https://root-forum.cern.ch/t/tmultigraph-not-drawing-all-data/41556/3 "2020-09-23T11:34:09Z")

</div>

Try moving these lines

```auto
      g->GetXaxis()->SetTitle("Energy (MeV)");      
      g->GetYaxis()->SetTitle("Energy Deposited");

```

after adding the graphs to the multigraph, or after drawing it.

---

<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:** [September 23, 2020, 11:46am UTC](https://root-forum.cern.ch/t/tmultigraph-not-drawing-all-data/41556/4 "2020-09-23T11:46:18Z")

</div>

[Graph\_Coherent\_Detect.C](https://root-forum.cern.ch/uploads/short-url/vtBsmZoXb9f4THLACOUTuCCPtgT.C) (2.8 KB)

 ![Screenshot 2020-09-23 at 13.45.32](https://root-forum.cern.ch/uploads/default/original/3X/5/0/50520c32a951bdf6807e8e23f42258d8a41b08d2.jpeg)  
The legend drawing was also misplaced.

---

<div class="post-metadata">

**Author:** ![AleCalamida](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@AleCalamida](https://root-forum.cern.ch/u/AleCalamida)\
**Post date:** [September 23, 2020, 12:55pm UTC](https://root-forum.cern.ch/t/tmultigraph-not-drawing-all-data/41556/5 "2020-09-23T12:55:07Z")

</div>

Yes, I knew it that I had to replaced the legend but I left this problem for later. The problem was that I obtain this plot usig TGraphError and no with TMultiGraph.

Alessandro.

---

<div class="post-metadata">

**Author:** ![AleCalamida](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@AleCalamida](https://root-forum.cern.ch/u/AleCalamida)\
**Post date:** [September 23, 2020, 1:29pm UTC](https://root-forum.cern.ch/t/tmultigraph-not-drawing-all-data/41556/6 "2020-09-23T13:29:55Z")

</div>

Now he is not writing the name of the axes anymore.

Alessandro.

---

<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:** [September 23, 2020, 2:41pm UTC](https://root-forum.cern.ch/t/tmultigraph-not-drawing-all-data/41556/7 "2020-09-23T14:41:09Z")

</div>

do:

```auto
   g->GetXaxis()->SetTitle("Energy (MeV)");
   g->GetYaxis()->SetTitle("Energy Deposited");
   gPad->Modified();
   gPad->Update();

```

---

<div class="post-metadata">

**Author:** ![AleCalamida](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@AleCalamida](https://root-forum.cern.ch/u/AleCalamida)\
**Post date:** [September 23, 2020, 2:43pm UTC](https://root-forum.cern.ch/t/tmultigraph-not-drawing-all-data/41556/8 "2020-09-23T14:43:38Z")

</div>

> [@couet](#):
>
> ```auto
> gPad->Modified();
> gPad->Update();
> 
> ```

Now everything works perfectly. Thank you very much. So, when I use multgraph I have to pay attention where I place the instruction for the axis?

Alessandro.

---

<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:** [September 23, 2020, 2:48pm UTC](https://root-forum.cern.ch/t/tmultigraph-not-drawing-all-data/41556/9 "2020-09-23T14:48:36Z")

</div>

Yes the multigraph needs to know all the graph it contains before drawing it. At drawing time the axis limits are computed in a such way all the graphs are entirely visible. Therefore the final axis are computed at drawing time. That’s why the axis are valid only after drawing.
