Changing Labels on X-Axis + no points are visible in the .tex document

In the following script I would like to change on the X-Axis the 0 to a 100 and delete the labels for 3000/5000/6000/7000. I successfully get the Xaxis with TAxis* a = G1->GetXaxis(); and adjust the labeling with
a->SetNdivisions(510, kTRUE); But when I would like to change the label with a->ChangeLabel(0,-1,-1,-1,-1,-1,“100”); I get an error.

I am obviously following the example in https://root.cern/doc/master/classTGaxis.html#GA10a without any success.

Additionally, the bid dots of MarkerStyle 8 are not visible as soon as I insert the .tex document in a Latex file.

Thanks a lot in advance. Here are the files:
1000_stats.txt (40 Bytes)
2000_stats.txt (41 Bytes)
4000_stats.txt (42 Bytes)
8000_stats.txt (41 Bytes)
100_stats.txt (39 Bytes)
original.c (5.2 KB)

You macro has C++ issues:

Processing original.c...
In file included from input_line_11:1:
/Users/couet/Downloads/original.c:165:18: warning: implicit conversion from 'double' to 'Width_t' (aka 'short') changes value from 2.5 to 2 [-Wliteral-conversion]
G1->SetLineWidth(2.5);
    ~~~~~~~~~~~~ ^~~
/Users/couet/Downloads/original.c:191:18: error: redefinition of 'm'
        TMarker *m = new TMarker(1000,y, 7);
                 ^
/Users/couet/Downloads/original.c:183:18: note: previous definition is here
        TMarker *m = new TMarker(100,y, 7);
                 ^
/Users/couet/Downloads/original.c:199:18: error: redefinition of 'm'
        TMarker *m = new TMarker(2000,y, 7);
                 ^
/Users/couet/Downloads/original.c:183:18: note: previous definition is here
        TMarker *m = new TMarker(100,y, 7);
                 ^
/Users/couet/Downloads/original.c:207:18: error: redefinition of 'm'
        TMarker *m = new TMarker(4000,y, 7);
                 ^
/Users/couet/Downloads/original.c:183:18: note: previous definition is here
        TMarker *m = new TMarker(100,y, 7);
                 ^
/Users/couet/Downloads/original.c:215:18: error: redefinition of 'm'
        TMarker *m = new TMarker(8000,y, 7);
                 ^
/Users/couet/Downloads/original.c:183:18: note: previous definition is here
        TMarker *m = new TMarker(100,y, 7);

Sry for the multiple definitions. Here is the correct version: original.c (5.2 KB)

I found two more mistakes:

  1. the function orginal() should be void because you never do return a TCanvas*
  2. SetLineWidth takes an int

I fixed both in my local copy of your macro. Now looking at your question

original.c (5.2 KB)

Thank you very much. That answers a lot. But I still have two problems:

  1. The dots with MarkerStyle 8 are not visible, when you plot the .tex file.
  2. I changed the Label 0 on the Axis with 100, but the picture in my paper is sadly too big so one notices the difference. Is there a way to add the label 100 at the axis position 100? Alternatively one coul just move the old 100 which was at the position of 0 slightly to the right.

Thanks in advance

Use marker style 20 instead of 8.

Changing the alignment to “left” will shift it a bit to the right but that might be not enough. If you want to place a label in some random place not related to the real axis labelling the best might be to remove label 0 and draw 100 as a TText where you need it.

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