2

I am plotting and saving a pie Chart and want the legend to be closer to the chart than with no position specification.

When using This puts the legend inside my pie and when moving the legend even furher to the right eg 1.5 the text gets cut off in the jpg file.

slices <- c(1,33,39)
label <- c('obligatory school','Highschool','College or University')


plot_df <- data.frame(
  group = label,
  value = slices
)

bar<- ggplot(plot_df, aes(x="", y=value , fill=group))+  geom_bar(width = 1, stat = "identity")

pie <- bar + coord_polar("y", start=0) +
   theme(plot.title = element_text(hjust = 0.5),  legend.text=element_text(size=15), legend.position=c(1,0.5))  #

print(pie)
ggsave('test.jpg',width = 10, height = 8, dpi = 150, units = "in")


Why is the plot behaving that way and how can I get my legend just outside of my Chart without it beeing cut of?

Katsuyo
  • 63
  • 1
  • 5

0 Answers0