Reputation: 38003
I'm having some difficulty with the Cairo PDF device when saving ggplot objects.
I ran this code:
library(ggplot2)
p <- ggplot(mpg, aes(displ, cty)) +
geom_point() +
facet_wrap(~ year)
ggsave("test.pdf", plot = p, device = cairo_pdf)
When inspecting the output in illustrator (Inkscape should show the same thing), I notice that for example on the x-axis, the numbers 2-6 are all part of the same text element. Ideally, I'd have every axis label as a separate text element. I've emphasised that below by giving text a background fill colour:
Moreover, text kerning seems just awful. Notice for example the strip title for the '2seater' class. In black is the output and in red is the same text but with regular kerning. It's hard to spot differences, but you can see for example that the black 's' and 'e' are closer together, as well as the 't' and 'e'.
Is there a way to turn these things (automatically merging of text, weird kerning) off in the cairo pdf device?
If it matters, the code was run on Ubuntu 20.04.3 LTS on R4.0.5 with ggplot2 3.3.5.
Upvotes: 4
Views: 766
Reputation: 712
I have the same issue with the lackluster kerning from cairo_pdf
. I have had better luck with the Cairo package Cairo::Cairo
device, though it isn't as good printing math symbols (subscripts seem to get messed up on my system).
Upvotes: 1