The problem: Images can be abstracted and embedded, obscuring their context or data provenance. This can lead to preliminary, dummy, or simulation results being confused for a final result or privileged/confidential results being accidentally disseminated.
The solution: Image watermarks can’t be easily removed by cropping and embedding by the lay user, don’t obscure results, and provide information about data provenance and information sensitivity. These can be added in your software package of choice, so that no post-processing of images is necessary, and can be easily suppressed in final results by flag variables.
The tools:
- mtext, text: add text to margins (mtext) or within the plot (text)
- grconvertX, grconvertY: find coordinates in a device, independent of axes
- rgb: create translucent text from RGB values
run.date <- format(Sys.Date(), "%m-%d-%Y")
png(paste0("Watermark 1 - ", run.date, ".png"))
plot(rnorm(100))
text(x = grconvertX(0.5, from = "npc"), # align to center of plot X axis
y = grconvertY(0.5, from = "npc"), # align to center of plot Y axis
labels = "CONFIDENTIAL", # our watermark
cex = 3, font = 2, # large, bold font - hard to miss
col = rgb(1, 0, 0, .2), # translucent (0.2 = 20%) red color
srt = 45) # srt = angle of text: 45 degree angle to X axis
# Add another watermark in lower (side = 1) right (adj = 1) corner
watermark <- paste("Data embargo until", run.date)
mtext(watermark, side = 1, line = -1, adj = 1, col = rgb(1, 0, 0, .2), cex = 1.2)
dev.off() # close device, create image
The result:
Watermarks in ggplot2 and lattice:
- R-bloggers: Adding watermarks to ggplot2
- StackOverflow: Inserting images and text in lattice
No comments:
Post a Comment