[R] comma as decimal separator in plots

Thomas Petzoldt petzoldt at rcs.urz.tu-dresden.de
Sat Jan 19 14:21:47 CET 2002



Antonio Olinto wrote:
> 
> Hi,
> 
> Some time ago I asked about how to use comma as decimal separator in plots

[...]

> This was very useful to me, but in the example:
> 
> x <- rnorm(50, mean=2, sd=0.1)
> y <- rnorm(50, mean=2, sd=0.2)
> plot(x,y)
> axis(1,at=pretty(x),labels=chartr(".", ",", as.character(pretty(x))))
> axis(2,at=pretty(y),labels=chartr(".", ",", as.character(pretty(y))))
> 
> I got an "2" in the middle of  the "2.0". How could I avoid it?

The mistake in your example is, that you draw two sets axes, one with
dot and one with comma.

You should suppress the default axes in the plot() function:

plot(x,y, axes=FALSE)
box()
axis(1,at=pretty(x),labels=chartr(".", ",", as.character(pretty(x))))
axis(2,at=pretty(y),labels=chartr(".", ",", as.character(pretty(y))))

Thomas Petzoldt

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list