简体   繁体   中英

Making pie chart's contours smoother on Shiny

I am trying to have a nice looking plot for two (or possibly more) continuous values in the form of a pie chart using ggplot2 .
The code is the following :

library("ggplot2")
library("ggthemes") ## for theme_economist
df <- data.frame(origin=c('with','without'),value=c(24536,50456))  
pie <- ggplot(df, aes(x = "",y=value, fill = origin))+  
    geom_bar(width = 1,stat="identity")+  
    coord_polar(theta = "y",start=pi/3)+  
    theme_economist()

馅饼
The pie is relatively fine except that the contours of the pie seems to be a bit irregularly drawn.Of course when you export it as a pdf it looks fine but displayed in RStudio or Shiny it doesn't look nice at all.
Is there a way to change the resolution of the ggplot object directly or to make renderplot() aware that we want to display the image at a high resolution ? I tried modifying the res argument of the renderPlot() function but it distorts the image and do not get rid of the irregularity of the border.

How to make the contours of the pie smoother on Shiny or RStudio directly ? Thanks.

To improve the resolution of the plot on Shiny you have to set the res argument to its default value of 72. It does not make a lot of sense to me but it worked just fine the resolution went from really bad to really nice !
However increasing its value further can lead to distortion of the image.
It seems that for now you cannot change the resolution of the plotting object itself before exporting it or rendering it into Shiny.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM