Export plot in .png with transparent background

只愿长相守 提交于 2019-12-21 07:06:33

问题


I am trying to export a simple plot in .png with transparent background. I am able to export it, but the background stays white.

Mock example

x = c(1, 2, 3)

I've tried this

plot (x)

dev.copy (png,'myplot.png', bg = 'transparent')
dev.off()

And this

plot (x, bg = 'transparent')

dev.copy (png,'myplot.png')
dev.off()

But neither work.

Can someone help?


回答1:


x = c(1, 2, 3)
par(bg=NA)
plot (x)

dev.copy(png,'myplot.png')
dev.off()


来源:https://stackoverflow.com/questions/43614863/export-plot-in-png-with-transparent-background

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!