Measure Ink Area

I read about the relationship between data and Tufte ink, and I was wondering if it is possible to measure the amount of β€œink” that the plot uses?

If this is not possible in R, perhaps with another tool like GIMP or imagemagick?

+6
source share
1 answer

I would suggest using grid.cap() to convert the contents of the graphics device to bitmap, and then just calculate the fraction of non-white pixels (in other words, β€œink”). In the following example, in order to focus the calculations on the ink in the graph area, I set par(mar=c(0,0,0,0)) , but you can drop this line if you want to also study the amount of ink in the axes, ticks, axis labels, header, etc.

 library(grid) ## Plot to R 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 (ie are inked in) sum(p!="white")/length(p) # [1] 0.2414888 ## Restore pre-existing graphical parameters par(opar) 
+6
source

All Articles