[R] axis.break on Date-x-axis in lattice xyplot
Jim Lemon
jim at bitwrit.com.au
Mon Jul 28 14:12:12 CEST 2008
On Mon, 2008-07-28 at 12:19 +0200, Henning Wildhagen wrote:
> Dear list,
>
> i am using the following code to produce a lattice xyplot, but the
> axis.break-function is seemingly not executed.
>
> Date<-seq(as.Date("2006-08-29"), as.Date("2007-08-28"), by="2 weeks")
> Period<-
> var1<-rnorm(27, 90000000, 30000000)
> var2<-rnorm(27, 500000000,250000000)
> var3<-rnorm(27, 1000000,500000)
> var4<-rnorm(27, 600000,300000)
> var5<-rnorm(27, 50000, 25000)
>
> Start<-as.Date("2006-08-01") ##1. August 2006
> End<-as.Date("2007-09-01") ##31. August 2007
> Periode<-seq(Start, End, by="month")
>
> df<-data.frame(Date,var1,var2,var3,var4,var5)
>
> library(reshape)
>
> df<-melt(df, id="Date")
>
> library(lattice)
> library(plotrix)
>
> P<-xyplot(df$value~df$Date|df$variable,
>
> scales=list(x=list(at=Periode,rot=60,tck=-1,format="%d.%b.%Y",alternating=F),
> y=list(relation="free",rot=0
> )),
> axis.break(axis=1,
> breakpos="2007-01-01",style="gap",bgcol="white",breakcol="black",brw=0.1)
> )
>
> This code is resulting in an error, the problem is the specification of
> the breakpos-Argument, but I dont know what "user units" in this case
> are.
>
Sorry Henning,
axis.break may have some problems in the lattice environment. The "user
units" don't necessarily correspond to what is on the plot, nor can you
necessarily add things to a plot that is displayed. Unfortunately, I
can't get your example to run (I get "Error in as.vector(x, mode) :
invalid 'mode' argument"), so I can't suggest how you might get around
this.
Jim
More information about the R-help
mailing list