[R] Legends dissapearing from scatterplot (car package) when using logarithmic axis

Helmer Belbo hbelbo at gmail.com
Mon Sep 14 22:43:20 CEST 2009


Dear R-people

I am struggling with disappearing legend box when using logarithmic
axis in scatterplot.

Sample code:

###############
library(car)
#constructing data set
x=rep(1:50, 2);
ClassDummy=rep(1:2, each=50) ;
y=5+ClassDummy+(rnorm(100,mean=(50/x),sd=(10/x)))
mydata <- data.frame (cbind('x'=x, 'ClassDummy'=ClassDummy, 'y'=y))
mydata$Class<-rep(c('a', 'b'),each=50)

# Plotting wiht regular axis
scatterplot(y~x | Class, reg.line=FALSE,
  smooth=FALSE, labels=F, boxplots='xy', by.groups=FALSE, data=mydata )

#Plotting with logarithmic axes
scatterplot(y~x | Class, reg.line=FALSE, log="xy",
  smooth=FALSE, labels=F, boxplots='xy', by.groups=FALSE, data=mydata )

###################

When using regular axis the legend box shows up.
When using logarithmic axis the legend box does not show up.

>From the R console i get the following error message:

           Warning message:
           In log(-0.0679588001734407, 10) : NaNs produced

So; what is the problem here? How do I get the legend box when using
logarithmic axis?

System info: OS - Windows XP, R version 2.9.2, "car" package up to
date by Sept. 14th 2009.

Regards
Helmer




More information about the R-help mailing list