In the following picture you can see the same part of a ggplot graph, created in two different (windows) machines. Above each graph I have written the versions of the related packages. I am not using any font family
setting in the ggplot call. Why do I get different fonts with the most recent version? (The change reminds me of the effect that Cleartype
setting has in smoothing font edges)
ggplot allows you to change the font of each part of the figure: you just need to know the correct option to modify in the theme. (For a full list of customizable components of the theme, see this documentation.)
You might want to take a look at this page, http://wiki.stdout.org/rcookbook/Graphs/Fonts/, for some tips on dealing with font issues with ggplot/ggplot2. Also there is an example R
script that will generate a table of all the fonts rendered so you can compare them a little easier between the 2 systems.
fonttable <- read.table(header=TRUE, sep=",", stringsAsFactors=FALSE,
text='
Short,Canonical,
mono,Courier,
sans,Helvetica,
serif,Times
,AvantGarde
,Bookman
,Helvetica-Narrow
,NewCenturySchoolbook
,Palatino
,URWGothic
,URWBookman
,NimbusMon
URWHelvetica,NimbusSan
,NimbusSanCond
,CenturySch
,URWPalladio
URWTimes,NimbusRom
')
fonttable$pos <- 1:nrow(fonttable)
library(reshape2)
fonttable <- melt(fonttable, id.vars="pos", measure.vars=c("Short","Canonical"),
variable.name="NameType", value.name="Font")
# Make a table of faces. Make sure factors are ordered correctly
facetable <- data.frame(Face = factor(c("plain","bold","italic","bold.italic"),
levels = c("plain","bold","italic","bold.italic")))
fullfonts <- merge(fonttable, facetable)
library(ggplot2)
pf <- ggplot(fullfonts, aes(x=NameType, y=pos)) +
geom_text(aes(label=Font, family=Font, fontface=Face)) +
facet_wrap(~ Face, ncol=2)
pf
You can run it like so:
% R
> source ("make_font_table.R")
> pf
NOTICE: Only some of the fonts (Timea, Helvetica, Courier) are actually getting rendered.
Also you might want to check out the extrafont-package. Finally this post shows how to use the extrafont-package so that you get better looking fonts rendered in your output.
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