删除中央白色圆圈?

标签 r plot ggplot2 geometry

我有一个圆形图,我想找到一种方法来去除中间的白色小圆圈。

这是我的代码:

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())

enter image description here

您与 limits 走在正确的轨道上和 expand scale_y 的参数,您只需要弄清楚实际下限在哪里。为此,让我们绘制没有 coord_polar 的相同集合没有您的 scale_y .

enter image description here

所以在我的例子中,瓷砖的最小边缘是 y=0.5 .所以你必须弄清楚你最小的是什么y值是,然后减去默认值的一半 heightgeom_tile (这是 1)。将该值用于较低的 y限制,你的馅饼上的洞就会消失。

enter image description here

关于删除中央白色圆圈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44593112/

相关文章:

r - 优化具有许多 'layers' 的详细 map 的 Shiny + Leaflet 性能

r - 处理不完整的案例并进行估算?

matlab - MATLAB 中 Surf 图的面积计算

r - 如何对齐多行标题

r - 使用前一行值进行列计算,无需循环

r - 将 `purrr::map` 与组合函数一起使用

r - knitr:以 pdf 和 png 格式保存图形,但在最终文档中使用 pdf 文件

image - 如何在 MATLAB 中的图像上画一个圆圈?

r - 如何在ggplot2上将图例符号与包装的图例文本对齐

r - 从 lmer 对象中提取处理方法并计算误差线