Set X-Y Labels/Range in a TMultiGraph Object using the 3D Draw option

Hi Everyone,

I wonder if there is a way to change the X and Y titles for a
TMultiGraph object which have been drawn with the “al3d” option. Here I
send a slightly modified version of the example shown in the documentation:

   auto c0 = new TCanvas("c1","multigraph L3",200,10,700,500);
   auto mg = new TMultiGraph();
   auto gr1 = new TGraph(); gr1->SetLineColor(kBlue);
   auto gr2 = new TGraph(); gr2->SetLineColor(kRed);
   auto gr3 = new TGraph(); gr3->SetLineColor(kGreen);
   auto gr4 = new TGraph(); gr4->SetLineColor(kOrange);
   Double_t dx = 6.28/100;
   Double_t x  = -3.14;
   for (int i=0; i<=100; i++) {
      x = x+dx;
   mg->Add(gr4); gr4->SetTitle("Cos(x*x*x)"); gr4->SetLineWidth(3);
   mg->Add(gr3); gr3->SetTitle("Cos(x*x)")  ; gr3->SetLineWidth(3);
   mg->Add(gr2); gr2->SetTitle("Cos(x)")    ; gr2->SetLineWidth(3);
   mg->Add(gr1); gr1->SetTitle("2*Sin(x)")  ; gr1->SetLineWidth(3);
   mg->SetTitle("Title; XX; YY");

Note that I also tried to get a pointer to the axis to change its title
after drawing the TMultiGraph as stated in the documentation but I got
an Illegal Pointer error. Also, is there any way to specify the range
for each axis?

Any help would be appreciated,


Best wishes,

Yes you are right this in not implemented.
The way to do it right now would be to add a text near the axis.

Hi Olivier,

Should I create an Issue on Jira about it or is it already open?


Yes you can create one.

Hi Olivier,

Is it also possible to set the range of the axis now? I was using
mg->GetXaxis()->SetRangeUser(min,max) but it didn’t work before.



I made sure it works for the titles … but for the ranges more development are needed. I will check

The Range is implemented now.

Great! Thank you. As soon as I have the chance to install the latest
version I’ll try those functions.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.