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)
(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.)
To change the text font for any chart element, such as a title or axis, right–click the element, and then click Font. When the Font box appears make the changes you want.
Perhaps draw the axis and labels manually, rather than accepting the defaults?
plot(-20:-1, rnorm(20) + 1 : 20, xaxt="n")
Axis(-20:-1, at=seq(-20,-5,5), side=1,
labels=paste("\U2212",seq(20,5,-5),sep=""))
Another way which is almost the same as the one provided by Joshua Ulrich, except that you can let R compute the axis ticks :
plot(-20:-1, rnorm(20) + 1 : 20, xaxt="n")
at <- axTicks(1, usr=par("usr")[1:2])
labs <- gsub("-", "\U2212", print.default(at))
axis(1, at=at, labels=labs)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With