I am using lattice for a bar plot, having a little trouble removing ticks, tick labels from x-axis, but keeping them on the y-axis. I looked around quite a bit (http://tolstoy.newcastle.edu.au/R/e7/help/09/06/1733.html, help pages, etc), tried variations of "scales = list(alternating = c(0,0)", "scales = list(alternating = c(0,0), tck = c(0,0))" and others, couldn't quite get it. #My code: tC <- textConnection(" Time Type1 Type2 Type3 1.3 .50 .25 .25 4.5 .55 .25 .20 5.2 .65 .20 .15 ") data1 <- read.table(header=TRUE, tC) data2 <- data.frame(Time=rep(data1$Time, 3), stack(data1[,2:4])) close.connection(tC) rm(tC) require(lattice) plot1<-xyplot(values ~ Time, scales = list(alternating = c(0,0), tck c(0,0)), group=ind, data=data2, stack=TRUE, horizontal=FALSE, panel=panel.barchart, box.width=0.1, axes=FALSE, ylim=c(-0.05,1.05), xlim=c(0,6), main="Plot1") print(plot1, position=c(0,0,1,.6)) -- View this message in context: http://r.789695.n4.nabble.com/Lattice-place-ticks-only-on-y-axis-tp3684094p3684094.html Sent from the R help mailing list archive at Nabble.com.
On 2011-07-21 08:56, marcel wrote:> I am using lattice for a bar plot, having a little trouble removing ticks, > tick labels from x-axis, but keeping them on the y-axis. I looked around > quite a bit (http://tolstoy.newcastle.edu.au/R/e7/help/09/06/1733.html, help > pages, etc), tried variations of "scales = list(alternating = c(0,0)", > "scales = list(alternating = c(0,0), tck = c(0,0))" and others, couldn't > quite get it. > > #My code: > tC<- textConnection(" > Time Type1 Type2 Type3 > 1.3 .50 .25 .25 > 4.5 .55 .25 .20 > 5.2 .65 .20 .15 > ") > > data1<- read.table(header=TRUE, tC) > data2<- data.frame(Time=rep(data1$Time, 3), stack(data1[,2:4])) > close.connection(tC) > rm(tC) > > require(lattice) > plot1<-xyplot(values ~ Time, scales = list(alternating = c(0,0), tck > c(0,0)), group=ind, data=data2, stack=TRUE, horizontal=FALSE, > panel=panel.barchart, box.width=0.1, axes=FALSE, ylim=c(-0.05,1.05), > xlim=c(0,6), main="Plot1") > print(plot1, position=c(0,0,1,.6))Maybe just: xyplot(...., scales = list(x = list(draw = FALSE)), ....) Peter Ehlers> > > -- > View this message in context: http://r.789695.n4.nabble.com/Lattice-place-ticks-only-on-y-axis-tp3684094p3684094.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
Works perfectly, thank you. -- View this message in context: http://r.789695.n4.nabble.com/Lattice-place-ticks-only-on-y-axis-tp3684094p3685625.html Sent from the R help mailing list archive at Nabble.com.
I notice that with this solution there are still y-axis tick marks on both sides of the plot. Is there a way to remove the ones on the right side? -- View this message in context: http://r.789695.n4.nabble.com/Lattice-place-ticks-only-on-y-axis-tp3684094p3686638.html Sent from the R help mailing list archive at Nabble.com.
See the "alternating" parameter in the "scales" parameter list of ?xyplot. Presumably, something like: xyplot( ..., scales = list(..., alternating = 1),... ) is what you want. -- Bert On Fri, Jul 22, 2011 at 6:07 AM, marcel <marcelcurlin at gmail.com> wrote:> I notice that with this solution there are still y-axis tick marks on both > sides of the plot. Is there a way to remove the ones on the right side? > > -- > View this message in context: http://r.789695.n4.nabble.com/Lattice-place-ticks-only-on-y-axis-tp3684094p3686638.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- "Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions." -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics
On 2011-07-22 07:42, Bert Gunter wrote:> See the "alternating" parameter in the "scales" parameter list of > ?xyplot. Presumably, something like: > > xyplot( ..., > scales = list(..., alternating = 1),... )I would just use tck=c(1,0): xyplot(..., scales = list(tck = c(1,0), x = list(draw = FALSE)), ...) Peter Ehlers> > is what you want. > > -- Bert > > On Fri, Jul 22, 2011 at 6:07 AM, marcel<marcelcurlin at gmail.com> wrote: >> I notice that with this solution there are still y-axis tick marks on both >> sides of the plot. Is there a way to remove the ones on the right side? >> >> -- >> View this message in context: http://r.789695.n4.nabble.com/Lattice-place-ticks-only-on-y-axis-tp3684094p3686638.html >> Sent from the R help mailing list archive at Nabble.com. >> >> ______________________________________________ >> 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. >> > > >