I got a comment on a figure I submitted for publication, and by testing just realized something I was not aware of before: When using the bitmap-drivers, R seems to use a hyphen instead of a proper minus symbol for negative values on the axes. Is there any way to correct that?
library(extrafont)
loadfonts(device="win", quiet=TRUE)
png("Test.png", family="Helvetica", width=5, height=5, units="in", res=300)
plot(-3:3, -3:3)
text(-2, 2, labels=("\u2010 Hyphen"), pos=4)
text(-2, 1.5, labels=("\u002d Hyphen-Minus"), pos=4)
text(-2, 1, labels=("\u2212 Minus"), pos=4)
dev.off()
If you look at the image, the negative numbers on the axes are clearly labeled incorrectly with hyphens instead of minus symbols.
When using the pdf()
-driver, the negative values correctly use minus. I am aware that for the pdf()
-driver, this can be changed by using cairo-pdf()
. However, using another type (e.g. type="windows"
) in either the png()
- or tiff()
-driver does not change the hyphens to minus-signs.
Is there any way to use proper minus symbols for negative axis values using the bitmab-drivers?
It's rather complicated in base r. The following code prints axes after the plot itself. The hyphen in the axis lables are replaced with minus by find&replace.