测量绘图的"墨水"

ECI*_*CII 6 plot visualization r image gimp

我正在阅读Tufte的数据墨水比率,我想知道是否有可能测量一个情节使用的"墨水"量?

如果在R中不可能使用其他工具,如GIMP或imagemagick?

Jos*_*ien 6

我建议使用grid.cap()将图形设备的内容转换为光栅,之后计算非白色像素(也就是"墨水")的比例是一件简单的事情.在下面的示例中,为了将计算集中在绘图区域中的墨水上,我已设置par(mar=c(0,0,0,0)),但如果您还要检查轴,刻度,轴标签,标题等中的墨水量,则可以删除该行.

library(grid)

## Plot to R's default graphical device
opar <- par(mar=c(0,0,0,0))
plot(rnorm(1e4), rnorm(1e4), pch=16) 

## Capture contents of the graphics device as a raster (bitmap) image
p <- grid.cap()

## Compute the proportion of pixels that are not white (i.e. are inked in)
sum(p!="white")/length(p)
# [1] 0.2414888

## Restore pre-existing graphical parameters
par(opar)                    
Run Code Online (Sandbox Code Playgroud)