I know from How to avoid label overlap in pie chart that I can use ggrepel
to make labels not overlap in a pie graph. I would like percentages less than 7% moved to the outside and numbers 7% or more on top of their slice of the pie. Any ideas?
library( ggrepel )
library( ggplot2)
library( dplyr)
library( scales )
library( reshape )
y <- data.frame(
state = c( "AR" ) ,
ac = c( 0.43 ) ,
man = c( 0.26 ) ,
ltc = c( 0.25 ) ,
care = c( 0.05 ) ,
dsh = c( 0.01 )
)
y2 <- melt( y , id.var="state" )
test <- ggplot( y2 , aes( x=1 , y=value , fill=variable )) +
geom_bar( width = 1 , stat = "identity" ) +
geom_text_repel( aes( label = paste( y2$variable , percent( value )) ) , position = position_fill( vjust = 0.5 ) , color="white" , size=5 ) +
coord_polar( "y" , start = 0 ) +
scale_fill_manual( values=c( "#003C64" , "#0077C8" , "#7FBBE3" , "#BFDDF1" , "#00BC87" ) )
test
So in this example, the 1% and 5% would be in the grey area.