开发者

Export symbol as png

开发者 https://www.devze.com 2022-12-28 18:51 出处:网络
I\'d like to export plotting symbols form R as a png graphic. But I haven\'t found a perfect way yet.

I'd like to export plotting symbols form R as a png graphic. But I haven't found a perfect way yet.

Using

png("symbol.png",width=20, height开发者_StackOverflow中文版=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()

creates a little border around the symbol (I'd like it to be transparent) and the symbol isn't filling the whole space.

Export symbol as png

Is there a more specific way of doing this ?


In addition to the margins, you need to eliminate axes and the space for them, and turn off the auto-extending of the axis limits:

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

The fg=NA part removes the foreground of the symbol which is the border of the circle. Hopefully this looks more like what you had in mind.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号