R 将符号导出为png

R 将符号导出为png,r,R,我想将绘图符号从R导出为png图形。但我还没有找到一个完美的方法 使用 png("symbol.png",width=20, height=20, bg="transparent") par(mar=c(0,0,0,0)) plot.new() symbols(1, 1, circles=0.3, bg=2, inches=FALSE, lwd=2, bty="n") dev.off() 在符号周围创建一个小边框(我希望它是透明的),并且符号没有填充整个空间 是否有更具体的方法执行此操作?

我想将绘图符号从R导出为png图形。但我还没有找到一个完美的方法

使用

png("symbol.png",width=20, height=20, bg="transparent")
par(mar=c(0,0,0,0))
plot.new()
symbols(1, 1, circles=0.3, bg=2, inches=FALSE, lwd=2, bty="n")
dev.off()
在符号周围创建一个小边框(我希望它是透明的),并且符号没有填充整个空间


是否有更具体的方法执行此操作?

除了边距之外,还需要消除轴及其空间,并关闭轴限制的自动延伸:

par(xaxs="i", yaxs="i")  # 'internal' axis style - no extending
par(xaxt="n", yaxt="n")  # remove axes
par(mgp=c(0,0,0))        # remove room for title and axis labels
par(mar=c(0,0,0,0))      # remove margins
symbols(0,0, circles=1, bg=2, fg=NA, inches=FALSE, bty="n", 
        xlim=c(-1,1), ylim=c(-1,1)) #ensure limits match the size of the circle

fg=NA
部分删除作为圆边界的符号的前景。希望这看起来更像您的想法。

除了边距之外,您还需要消除轴及其空间,并关闭轴限制的自动延伸:

par(xaxs="i", yaxs="i")  # 'internal' axis style - no extending
par(xaxt="n", yaxt="n")  # remove axes
par(mgp=c(0,0,0))        # remove room for title and axis labels
par(mar=c(0,0,0,0))      # remove margins
symbols(0,0, circles=1, bg=2, fg=NA, inches=FALSE, bty="n", 
        xlim=c(-1,1), ylim=c(-1,1)) #ensure limits match the size of the circle

fg=NA
部分删除作为圆边界的符号的前景。希望这看起来更像你的想法。

它正在变得更好(更居中),但仍然有黑色边框作为“L”。我添加了一个图像来说明这些轴。我编辑了回复以删除它们。事实上,它正在工作。边界消失了。现在唯一的缺点是,我不能把它集中起来。从上到左更近!你有什么想法吗?如果您使用png(“symbol.png”,width=20,height=20,bg=“transparent”)…您的代码…dev.off(),您会看到。它越来越好(更居中),但仍然有黑色边框作为“L”。我添加了一个图像来说明这些轴。我编辑了回复以删除它们。事实上,它正在工作。边界消失了。现在唯一的缺点是,我不能把它集中起来。从上到左更近!你有什么想法吗?如果您使用png(“symbol.png”,width=20,height=20,bg=“transparent”)…您的代码…dev.off(),您将看到。