Sunday 6 January 2019

r - Fix typography in axis labels

Preamble: I want to create publication-grade graphics from R without postprocessing. Other researchers at my institute always perform postprocessing in a graphics software (such as Adobe Illustrator). I am hoping to avoid this.



My gripe is that R doesn’t use the correct minus sign for negative numbers (especially in plot axes):



plot(-20:-1, rnorm(20) + 1 : 20)


plot with negative numbers




(I’ve circled the offenders for your consideration.)



As somewhat of a typography nerd (it’s true! Check my Careers CV!) this is unacceptable. I need to use the correct Unicode character ᴍɪɴᴜꜱ ꜱɪɢɴ (U+2212, “−”) here. A friend of mine achieves this by replacing all minus signs in Adobe Illustrator prior to publication but I can’t help but think that there must be a better way – from within R – to accomplish this; and one that doesn’t force me to manually replace all axis labels.



(I’m not currently using ggplot2 but if there’s a solution which only works with ggplot2 I’ll gladly take it.)

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...