我正在使用ggplot2andsf和tigris包来绘制一些地图(使用geom_sf())。我发现我无法关闭网格线,尽管打电话theme(panel.grid = element_blank()),这似乎是由于使用coord_sf.
这是一个非地图示例,这是重现我的问题的更简单方法
library(ggplot2)
dat <- data.frame(x=rnorm(10),
y=rnorm(10))
# grid lines, as expected
ggplot(dat, aes(x,y)) +
geom_point() +
theme_light()
# no grid lines, as expected
ggplot(dat, aes(x,y)) +
geom_point() +
theme_light() +
theme(panel.grid = element_blank())
# why does this have grid lines?
ggplot(dat, aes(x,y)) +
geom_point() +
coord_sf() +
theme_light() +
theme(panel.grid = element_blank())
我想使用coord_sf但也关闭网格线。


