Help with axis labels

Hi all,

I’m trying to make a figure but fails… I’ve attached a script and the output of it. The problem is of course that I can’t control the number of ticks and/or which labels are written next to the axis. In my example I would like something like one or two labels for y, but not 0 nor maxvalue as this interferes with the histogram above or below. For x I would like labels such as 595 and 615, but thats is!!!

Trying with SetNDivision got me nowhere…

cheers

Joa
HelpSpectra.C (3.21 KB)


Can you provide a running macro ? I get:

root [0] 
Processing HelpSpectra.C...
ring1row983
Error: illegal pointer to class object h 0x0 139  HelpSpectra.C:58:
*** Interpreter error recovered ***
root [1] 

Hi,

strange, it works for me with this configuration

csnwifi148:Downloads joa$ root-config --version
5.31/01
csnwifi148:Downloads joa$ uname -a
Darwin csnwifi148.in2p3.fr 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
csnwifi148:Downloads joa$ g++ --version
i686-apple-darwin10-g+±4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright © 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

also when trying the script downloaded from this forum, in case I had messed up uploading it…

Anyway, here is the same script, but in named version that can be compiled, works like a charm here

csnwifi148:Downloads joa$ root -l
root [0] .L HelpSpectra.C++
Info in TUnixSystem::ACLiC: creating shared library /Users/joa/Downloads/./HelpSpectra_C.so
root [1] HelpSpectra()
ring1row983
ring2row983
ring3row983
ring1row978
ring2row978
ring3row978
ring1row973
ring2row973
ring3row973
ring1row968
ring2row968
ring3row968
ring1row960
ring2row960
ring3row960
ring1row950
ring2row950
ring3row950
Info in TCanvas::Print: file help.png has been created
root [2]

so, no real idea why the script didn’t work for you…

cheers

Joa
HelpSpectra.C (3.41 KB)

Ok, your new file is working for me .
May be the download went wrong yesterday.
I will modify it and send it back

See the attached file.



HelpSpectra.C (3.41 KB)

Hi,

thanks for the help, although it is a bit fragile. I changed the script so that it fills the histogram with a random number of entries between 60 and 6000 (as opposed to the 600 before). And then the y axis again becomes somewhat difficult to control. Is there a general way to do what I want? Can’t I tell an axis I want a label every 20 or something like that?

cheers

Joa
HelpSpectra.C (3.44 KB)


set the number of division to 204 at the beginning of the macro