Ggplot2 grafiklerini R'den PNG dosyalarına şeffaf arka plana sahip olarak vermem gerekiyor. Her şey temel R grafiklerle Tamam, ama ggplot2 ile hiçbir saydamlık:Ggplot2'yi kullanarak R'de şeffaf arka planlı grafikler nasıl oluşturulur?
d <- rnorm(100) #generating random data
#this returns transparent png
png('tr_tst1.png',width=300,height=300,units="px",bg = "transparent")
boxplot(d)
dev.off()
df <- data.frame(y=d,x=1)
p <- ggplot(df) + stat_boxplot(aes(x = x,y=y))
p <- p + opts(
panel.background = theme_rect(fill = "transparent",colour = NA), # or theme_blank()
panel.grid.minor = theme_blank(),
panel.grid.major = theme_blank()
)
#returns white background
png('tr_tst2.png',width=300,height=300,units="px",bg = "transparent")
p
dev.off()
ggplot2 ile şeffaf bir arka plan almak için herhangi bir yolu var mı?
bakınız [Bu yanıt] (http://stackoverflow.com/questions/41856399/how-plot-transparent-background-ggplot), mevcut sol ution, 'theme (panel.background = element_rect (fill = "transparent", color = NA), plot.background = element_rect (fill = "transparent", color = NA)) eklemek için' –