TMultigraph not drawing all data

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 (4.3 KB) Detect_0_Alp_Trig.txt (31.7 KB) Detect_0_Alp_No_Trig.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

I 'll look

Try moving these lines

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

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

Graph_Coherent_Detect.C (2.8 KB)

The legend drawing was also misplaced.

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.


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



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

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?


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.