Home | News | Documentation | Download

Strange behaviour (bug?) with TGaxis

Firstly I must appologize for what will probably be a bit of a vague question - I have only limited information at the moment.

Below is a screenshot of some output from my analysis code.

On the bottom figure you can see that I have placed a TGaxis. It is in an unusual location, however this is because I placed it so.

Of more importance is the offset of the labels. The labels intersec the axis ticks. I do not understand why this is the case, and I have not set this behaviour (to my knowledge) in my code. Hence I believe it may be a bug.

I am asking this question for another reason - I recently experienced some crashing of my drawing code. I managed to isolate the issue to be related to the plotting of this axis. At the moment I don’t know anything more than this.

It could possibly be related to this issue, but I do not know for sure.

I don’t expect this to be terribly useful, however this is the code related to the drawing of that axis.



Here’s what I’ve learned so far… The issue goes away if I remove the “0.0001”.

I put this in here because I read somewhere in the documentation that the x values should not be exactly equal but perhaps I misunderstood for which direction of axis that should be.


I need a piece of code reproducing the issue (not screen shots please).

Try this

#include <TCanvas.h>
#include <TGaxis.h>

int main()

    TCanvas *c = new TCanvas("canvas", "canvas");
    TH1D *h = new TH1D("h", "h", 50, 0.0, 5.0);

    TGaxis *axis = new TGaxis(1.0, 0.5, 1.0 + 0.0001, 4.5, 0.5, 4.5, 503, "");
    TGaxis *axis2 = new TGaxis(2.0, 0.5, 2.0 - 0.0001, 4.5, 0.5, 4.5, 503, "");


    return 0;


Yes you axis you be vertical … other wise it is more tricky to setup.

void birdsall() {
   TCanvas *c = new TCanvas("canvas", "canvas");

   TGaxis *axis = new TGaxis(1.0, 0.5, 1.0 + 0.0001, 4.5, 0.5, 4.5, 503, "+L");
   TGaxis *axis2 = new TGaxis(2.0, 0.5, 2.0, 4.5, 0.5, 4.5, 503, "+L");


   TGaxis *axis7 = new TGaxis(4,0.5,4,4.5, 0,9000,503,"+L");

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