How to remove a coordinate in a pie chart generated by ggplot2

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: enter image description here

Created using 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 to remove the following:

  • A circular coordinate, for example. (0, 10,000, 20,000,30000).
  • Y coordinate (e.g. 1)
  • White circle.
+7
r plot ggplot2
source share
1 answer

You can remove these elements using the appropriate arguments in the 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()) 

enter image description here

After deleting the entire grid, you can manually add your own grid using geom_hline and geom_vline (see here .).

I recommend watching this tutorial .

+7
source share

All Articles