0

I'm having trouble with the ggsave() function due to what is likely a font-related issue.

When I try to run ggsave:

ggsave("new_plots/figure_1.pdf",
   height = 3.7,
   width = 6)

I get the following error message:

Error in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, : invalid font type

I've installed the custom font "Gotham", and have imported it with the extrafont package. It shows up in the console when I run "fonts()". However, when I try to load it for PDF use with loadfonts(device = "PDF"), it does not figure on the list.

Any ideas as what to do?

These are my theme settings:

theme_idh <- 
theme_minimal() +
theme(panel.grid.major = element_blank(),
    panel.grid.minor = element_blank(),
    axis.ticks = element_line(colour = "grey80"),
    text = element_text(family = "Gotham"),
    axis.line = element_line(colour = "grey80")
    )
theme_set(theme_idh)
  • Have you tried this? `ggsave(filename = "your file name", plot = last_plot, units = "cm", width = 29, height = 20, dpi = 600)` – Kian Jun 08 '21 at 09:34
  • Then I get the following error message: Error in UseMethod("grid.draw") : no applicable method for 'grid.draw' applied to an object of class "function" – David Færgeman Jun 08 '21 at 09:44

0 Answers0