Titles of x,y axis

my code is not giving titles of axis i gave command but it not working then i used off set value but no effect x axis shows far away from borderline of axis after applying offaxis values. what should i do?

Hi,
can you post the minimal amount of code which reproduces your issue?

D

I do not know what the original author of this thread means but it reminded me about a bug that I met in ROOT 6.10/08 and 6.12/04 (I think older versions were fine).
The following macro draws the graph but the axes titles are not present (uncomment the one line below in order to get them):

{
  TGraph *g = new TGraph(2);
  g->SetMinimum(0.1); g->SetMaximum(10);
  g->SetNameTitle("g", "graph title;x axis title;y axis title");
  g->SetPoint(0, 1, 1); g->SetPoint(1, 2, 2);
  // g->SetTitle(g->GetTitle()); // bug fix: restore axes titles
  g->Draw("ALP");
}

Thank you for reporting. This is now ROOT-9222.

1 Like

This way of setting titles for graphs is not implemented. It should

Actually, this way of setting axes titles for graphs works fine in ROOT 5.34/36, “v5-34-00-patches” and 6.08/06.

Also, it one comments out the line which sets the “min” and “max”, or moves it further down in the code, it will magically start to work in newer ROOT versions.

i am using root version of 5.34 but its not picking up titles.

oohh no its picking up titles but far away from axis margin line???
thanks in advance

Try to remove “${HOME}/.rootrc” and/or “./.rootrc” (if they exist) and then start ROOT using root -n (if it then works, check any existing “.rootrc” and/or “rootlogon.C” files).


these lines are not there.

It’s clear that your macro defines the sizes and offsets of the axes titles. You either need to remove these calls or tune them manually to what you want.

yes here is a size 1.2 then titles was far away as x axis u can see in plot but then i put it o.6 for x and y axis then it give me plot with titles like this.

Now fixed. Thanks.
SetNameTitle was now changing the underlaying histogram name and title.
SetTitle was. The macro was working using SetTitle.

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