I want to have my ggplots on R Shiny Server have transparent. My ui.R for plotting is as follows:
plotOutput("malPie", width="95%")
in the server.R my plotting function is as follows:
c <- ggplot(dataFrame, aes(x=factor(nrow(dataFrame)),fill=graphX),environment=environment()) + geom_bar(width = 1)
print(c + coord_polar(theta = "y")+ xlab(xLabel)+ylab(yLabel)+ labs(fill=legendTitle)+ theme(
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
panel.background = element_blank(),
plot.background = element_blank()
))
and where it's called:
sub <- data
sub <- subset(sub,sub$mal_tested=="1")
drawGraph("pie",sub,factor(sub$mal_tested_pos),"Malaria Tests Done",NULL,"Malaria Tested Positive","Malaria")
But the graph rendered still has a white background and I want it to be transparent, not white. How do I achieve this? I have attached an image with an arrow showing the plot.
How do i change this background? Please help me.
As @baptiste indicated, you also need to pass bg="transparent"
to the renderPlot
call:
renderPlot({
...
}, bg="transparent")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With