Dr. Alireza Zolfaghari
2008-Oct-30 15:54 UTC
[R] xyplot, the first tick mark starts from 2 rather than 1, and also there is a NA as the final tick mark.
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) )) ################################################################################################################# Regards, Alireza [[alternative HTML version deleted]]
stephen sefick
2008-Oct-30 18:28 UTC
[R] xyplot, the first tick mark starts from 2 rather than 1, and also there is a NA as the final tick mark.
#try this library(ggplot2) 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)) qplot(Line, Loss, data=plotDATA)+scale_x_continuous(breaks=1:13) On Thu, Oct 30, 2008 at 11: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) > > )) > > ################################################################################################################# > Regards, > Alireza > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. >-- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
Deepayan Sarkar
2008-Oct-30 19:02 UTC
[R] xyplot, the first tick mark starts from 2 rather than 1, and also there is a NA as the final tick mark.
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