以透明背景导出.png中的图 [英] Export plot in .png with transparent background
本文介绍了以透明背景导出.png中的图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试导出 .png 中具有透明背景的简单绘图.我可以导出它,但是背景保持白色.
I am trying to export a simple plot in .png with transparent background. I am able to export it, but the background stays white.
模拟示例
x = c(1, 2, 3)
我已经尝试过
plot (x)
dev.copy (png,'myplot.png', bg = 'transparent')
dev.off()
还有这个
plot (x, bg = 'transparent')
dev.copy (png,'myplot.png')
dev.off()
但是都不行.
有人可以帮忙吗?
推荐答案
x = c(1, 2, 3)
par(bg=NA)
plot (x)
dev.copy(png,'myplot.png')
dev.off()
这篇关于以透明背景导出.png中的图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文