[R] xyplot, the first tick mark starts from 2 rather than 1, and also there is a NA as the final tick mark.

Deepayan Sarkar deepayan.sarkar at gmail.com
Thu Oct 30 20:02:29 CET 2008


On Thu, Oct 30, 2008 at 8:54 AM, Dr. Alireza Zolfaghari
<ali.zolfaghari at gmail.com> wrote:
> I am trying to plot some data, but have got some difficulties with labels on
> the tick marks on the x-axes. There are 20 data points. All I want to do is
> to plot the Loss versus Lines. When I use xyplot, the first tick mark starts
> from 2 rather than 1, and also there is a NA as the final tick mark.
>
> Here is the R code you code give it a try:
>
> Would any body be able to fix this, please?
>
> #################################################################################################################
>
> plotDATA=data.frame(Loss=c(1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10),Level=c("AvgAll","AvgAll","AvgAll","AvgAll","AvgAll","AvgAll","AvgAll",
>
> "AvgAll","AvgAll","AvgAll","AvgAll","AvgAll","GUL","GUL","GUL","GUL","GUL","GUL","GUL","GUL"),Line=c(1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8))
>
> library(lattice)
>
> xyplot( Loss ~ Line, data=plotDATA, t="p",
>
> scales=list(relation="free", x=list(draw=TRUE, tick.number=12,
>
> labels=1:12)
>
> ))
>
> #################################################################################################################

I think you want

xyplot( Loss ~ Line, data=plotDATA, scales=list(x=list(at = 1:12)) )

-Deepayan



More information about the R-help mailing list