如何删除ggplot2生成的饼图中的坐标

时间:2022-12-07 15:00:47

Given this data:

鉴于此数据:

abTcells    1456.74119
Macrophages 5656.38478
Monocytes   4415.69078
StemCells   1752.11026
Bcells  1869.37056
gdTCells    1511.35291
NKCells 1412.61504
DendriticCells  3326.87741
StromalCells    2008.20603
Neutrophils 12867.50224

This plot: 如何删除ggplot2生成的饼图中的坐标

Is generated with the following code:

使用以下代码生成:

library(ggplot2)                  
df <- read.table("http://dpaste.com/1697602/plain/");
ggplot(df,aes(x=factor(1),y=V2,fill=V1))+
   geom_bar(width=1,stat="identity")+coord_polar(theta="y")

How can I remove the following:

如何删除以下内容:

  1. Circular coordinate, e.g. (0, 10000, 20000,30000)
  2. 圆坐标,例如(0,10000,20000,30000)

  3. Y axis coordinate (e.g. 1)
  4. Y轴坐标(例如1)

  5. White circle.

1 个解决方案

#1


8  

You may remove these elements by using relevant arguments in theme:

您可以通过在主题中使用相关参数来删除这些元素:

ggplot(df, aes(x = factor(1), y = V2, fill = V1))+
  geom_bar(width = 1, stat = "identity") +
  coord_polar(theta = "y") +
  theme(axis.text = element_blank(),
        axis.ticks = element_blank(),
        panel.grid  = element_blank())

如何删除ggplot2生成的饼图中的坐标

After the entire grid is removed, you can manually add an own grid, using geom_hline and geom_vline (see here).

删除整个网格后,您可以使用geom_hline和geom_vline手动添加自己的网格(请参阅此处)。

I recommend having a look in this tutorial.

我建议你看看这个教程。

#1


8  

You may remove these elements by using relevant arguments in theme:

您可以通过在主题中使用相关参数来删除这些元素:

ggplot(df, aes(x = factor(1), y = V2, fill = V1))+
  geom_bar(width = 1, stat = "identity") +
  coord_polar(theta = "y") +
  theme(axis.text = element_blank(),
        axis.ticks = element_blank(),
        panel.grid  = element_blank())

如何删除ggplot2生成的饼图中的坐标

After the entire grid is removed, you can manually add an own grid, using geom_hline and geom_vline (see here).

删除整个网格后,您可以使用geom_hline和geom_vline手动添加自己的网格(请参阅此处)。

I recommend having a look in this tutorial.

我建议你看看这个教程。