ggplot2グラフィックスをRから透明な背景のPNGファイルに出力する必要があります。基本的なRグラフィックスではすべて問題ありませんが、ggplot2では透明度がありません。
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で背景を透明にする方法はありますか?
                  「opts」が廃止されたため、2番目の回答(YRCによる)を承認済みとしてマークすることを検討してください。
                
                
                  
                    —
                    Davit Sargsyan、
                    
                  
                
              
theme(panel.background = element_rect(fill = "transparent", colour = NA), plot.background = element_rect(fill = "transparent", colour = NA))