Exporting ggplot with extrafont using ggsave

165 views Asked by At

To have my plot match the font used for my writing, I added the font via the extrafont package. Thus, I performed the following procedure:

library(extrafont)
font_import()
loadfonts(device = "win")

This allowed me to change the font of my plot via a change of the theme. So far, so good. Now I want to export the plot using the ggsave() function. Unfortunately, the plot is exported without the new font, looking like this: Output without font

However, I want it to look like this: Wanted look

Now, I read up and found some people with similar issues. However, none of the proposed solutions worked for me. I tried to use the jpeg() and png() functions, however, the resulting quality is extremely bad; even when changing size and dpi manually, it does not seem to have an effect. Also, exporting as a pdf is not an option for me.

0

There are 0 answers