Integer values on x-axis of multi-graph

Hello, I’ve to set only integer values on the x-axis of a multi-graph becaues of the number of targets is an integer.
Following an example of @couet, I wrote

mg->GetXaxis()->SetNdivisions(8);

but the plot shows values as for example 2.5, 3.5 etc

emitarnum.cpp (2.4 KB)
Emittance_numb_target_C.txt (59 Bytes)
Emittance_numb_target_Be.txt (63 Bytes)

Thank you


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


https://root.cern/root/html606/classTAttAxis.html#ae3067b6d4218970d09418291cbd84084
Try experimenting yourself to understand it and find a value that works for what you want.

1 Like

There is several ways to achieve this, but as you already set the number of divisions in your macro, the simplest is:

mg->GetXaxis()->SetNdivisions(6);

Thanks to the both @dastudillo and @couet

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