问题
I want to remove the light gray grid lines from a Lattice dotplot. After searching R help pages, Sarkar's book, and the web, the one answer I've found is this post, which explains that you can set the grid line width to zero for all dotplots using this magic:
## turn off grid lines
d1 <- trellis.par.get("dot.line")
d1$lwd <- 0 ## hack -- set line width to 0
trellis.par.set("dot.line",d1)
Example: Try dotplot(VADeaths[,"Rural Female"])
before and after doing the preceding.
This solution works, but I would have thought that there would be a way to control the grid lines from inside the dotplot
function, perhaps using a panel function. Is there a way to do that? (An authoritative "No" could count as a correct answer.)
回答1:
Setting col.line = "transparent"
inside panel.dotplot
should solve this issue. See also ?panel.dotplot
.
dotplot(VADeaths[, "Rural Female"], panel = function(...) {
panel.dotplot(..., col.line = "transparent")
})
来源:https://stackoverflow.com/questions/35489624/remove-grid-lines-in-dotplot-without-modifying-underlying-trellis-parameters