Reputation: 3568
My issues with producing publication-grade figures in ggplot continue (see here)
Here's some reproducible code that throws the error.
library(bayesplot)
df <- data.frame(xVar = rnorm(1e4,0,1))
t <- bayesplot::mcmc_trace(df,"xVar")
t
All good. But when I try to save the figure as an eps (which many journals demand)
ggplot2::ggsave(filename = "tPlot.eps",
plot = t1,
device = "eps",
dpi = 1200,
width = 15,
height = 10,
units = "cm")
I get the error
Error in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)) :
family 'serif' not included in postscript() device
Has anyone encountered this sort of problem and found a solution?
Upvotes: 1
Views: 3391
Reputation: 12420
Fonts in plots is a tricky topic in R
. You might either not have the font or R
simply can't find it. You can look into the extrafont
package and try to hunt down the font on your system or download it. I would rather suggest to simply choose a different theme though:
library(bayesplot)
df <- data.frame(xVar = rnorm(1e4,0,1))
t <- bayesplot::mcmc_trace(df,"xVar") +
ggplot2::theme_bw()
t
ggplot2::ggsave(filename = "tPlot.eps",
plot = t,
device = "eps",
dpi = 1200,
width = 15,
height = 10,
units = "cm")
This got rid of the error on my machine.
Upvotes: 5