我有一个圆形图,我想找到一种方法来去除中间的白色小圆圈。
这是我的代码:
ggplot(d5)+geom_tile(aes(x=x, y=y, fill=xyz))+
scale_y_continuous(expand=c(0,0),breaks=NULL,limits=c(0,3.6))+
scale_fill_continuous(low="darkgreen", high="white")+
coord_polar(start=-1*pi/2, direction=1)+
theme_bw()+
theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank())
非常感谢。
最佳答案
我在这里做了一个虚拟示例:
require(dplyr)
expand.grid(x = 1:20, y = 1:2) %>%
mutate(z = rnorm(length(x))) %>%
ggplot()+geom_tile(aes(x=x, y=y, fill=z))+
scale_y_continuous(expand=c(0,0),breaks=NULL,limits=c(0,3.6))+
scale_fill_continuous(low="darkgreen", high="white")+
coord_polar(start=-1*pi/2, direction=1)+
theme_bw()+
theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank())
您与
limits
走在正确的轨道上和 expand
scale_y
的参数,您只需要弄清楚实际下限在哪里。为此,让我们绘制没有 coord_polar
的相同集合没有您的 scale_y
.所以在我的例子中,瓷砖的最小边缘是
y=0.5
.所以你必须弄清楚你最小的是什么y
值是,然后减去默认值的一半 height
为 geom_tile
(这是 1)。将该值用于较低的 y
限制,你的馅饼上的洞就会消失。关于删除中央白色圆圈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44593112/