Re: [R] Why does plot() ignore the data type for axis labels?

From: Stiffler <zoubidoo_at_hotmail.com>
Date: Tue, 19 Feb 2008 14:26:55 -0800 (PST)

Gavin Simpson wrote:
>

>> PS what's the right way to get integer labels?

>
> Do them by hand, if they are (numeric) integers
>
>> plot(x,y, axes = FALSE)
>> axis(2)
>> axis(1, at = x)
>> box()

>
> You could try writing your own Axis.integer function if doing the extra
> steps is a pain - something like:
>
> Axis.integer <- function(x = NULL, at = NULL, ..., side, labels = NULL)
> {
> at <- unique(x)
> labels <- as.character(at)
> axis(side = side, at = unique(x), labels = labels, ...)
> }
>
> which works in these case,
>
> y2 <- runif(3)
> plot(x, y)
> plot(x, y2)
>
> But is far from bullet proof and is not guaranteed to work in all
> situations.
>
> HTH
>

Thanks Gavin, I'll give that a try.

-- 
View this message in context: http://www.nabble.com/Why-does-plot%28%29-ignore-the-data-type-for-axis-labels--tp15562325p15574997.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_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.
Received on Tue 19 Feb 2008 - 22:36:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 19 Feb 2008 - 23:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive