Remove grid lines in dotplot without modifying underlying trellis parameters

谁说我不能喝 提交于 2020-08-26 07:41:49

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!