lith
2009-Sep-16 15:37 UTC
[R] lattice: How to display no box but only a y-axis on the left + Thicker lines
Hi, I have two somewhat embarassing questions about the lattice-related plot functions: 1.) How do I make lattice (e.g. barchart) to not draw a box but only a y-axis on the left hand side so that the plot looks like barplot with default settings? So that the following two code snippets look more alike: barplot(VADeaths) library(reshape) vad <- melt(data.frame(VADeaths, Age=rownames(VADeaths)), id="Age") barchart(value ~ variable, groups=Age, horizontal=FALSE, stack=TRUE, data=vad) 2.) What is the proper way to make lines in xyplots thicker? When I set lwd=2, I get thicker lines but in conjunction with lty=1:n they also look somewhat ugly which makes me wonder if I'm doing something wrong. I guess both questions are newbie questions and the information should be easily available somewhere. Unfortunately I wasn't able to find the answer to these questions myself. Regards, Tom
lith
2009-Sep-18 12:02 UTC
[R] lattice: How to display no box but only a y-axis on the left + Thicker lines
> 1.) How do I make lattice (e.g. barchart) to not draw a box but only a > y-axis on the left hand side so that the plot looks like barplot with > default settings?Does nobody have an idea? Or is the solution that obvious?
baptiste auguie
2009-Sep-18 13:06 UTC
[R] lattice: How to display no box but only a y-axis on the left + Thicker lines
No box is easy, bwplot(y~x, data=data.frame(y=rnorm(10),x=sample(letters[1:3],10,repl=T)), par.settings=list(axis.line=list(col=NA))) but that seems to remove all axis lines and ticks as well. You may have to define a custom panel.axis() function. An alternative is to use grid.remove() to remove the frame, bwplot(y~x, data=data.frame(y=rnorm(10),x=sample(letters[1:3],10,repl=T))) grid.remove("rect",grep=T,global=TRUE) HTH, baptiste 2009/9/18 lith <minilith at gmail.com>:>> 1.) How do I make lattice (e.g. barchart) to not draw a box but only a >> y-axis on the left hand side so that the plot looks like barplot with >> default settings? > > Does nobody have an idea? Or is the solution that obvious? > > ______________________________________________ > 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. >
baptiste auguie
2009-Sep-30 08:02 UTC
[R] lattice: How to display no box but only a y-axis on the left + Thicker lines
2009/9/30 lith <minilith at gmail.com>:>> Yes. You can get back the tick marks with scaless$col: > > Thanks for the hint. May I kindly ask what would be the easiest way to > draw a line on the left side?Try this, mpanel = function(...) { grid.segments(0,0,0,1) ; panel.bwplot(...) } bwplot(y~x, data=data.frame(y=rnorm(10),x=sample(letters[1:3],10,repl=T)), par.settings=list(axis.line=list(col=NA)), scales = list(col 1), panel=mpanel) HTH, baptiste> > Thanks, > Tom > > ______________________________________________ > 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. >