On 09/20/2009 02:12 PM, Shawn Polson wrote:
Hello,
I often use the axis command to add labels to axes with large numbers of
consecutively numbered names:
y<- barplot (x, log="x")
axis(1, at = y, labels = c(1:12345))
Since there are more labels than will fit in the space, the command only
prints selected labels. This is what I want, except that it never actually
prints a label for the final item. Thus I end up with labels something like
this:
1 16 123 1432 2134 3235 6578 11385
when I really want the last label displayed to be the final category number
(12345):
1 16 123 1432 2134 3235 6578 12345
Short of manually choosing the labels, does anyone know a way to force the
last category to be among those printed when axis selects labels?
Hi Shawn,
You can get the first and last label with:
axis(1,seq(1,12345,length.out=8)
but you have to specify how many labels you want, and you will get
non-integer labels unless the upper limit divides evenly.
Jim
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.