I am trying to save a ggplot2 plot in svg format. I am not using the ggsave function because the plot is generated as part of a knitr document - the device I specify for plotting is 'svg'.
The problem is that text elements from the original plot appear as paths in the svg file, at least when opened in inkscape. The source code of the svg does not look like it contains any text either.
My plotting function is defined in a separate file:
## @knitr plot_histogram
ggplot(mainFrame[complete.cases(mainFrame),])
+ geom_boxplot(aes(x=source, y = pPfam, fill = source))
+ scale_y_continuous(limits = c(0,1))
In the knitr document, I call the function and save the image using the 'svg' device.
```{r plot_histogram, dev = 'svg', fig.width= 7, fig.height=4, fig.show='hold', fig.path="figure/summary"}
```
So I'm not sure how to tell the 'svg' device or ggplot2 that I want to preserve text when saving svg? I would also be happy to use another graphics device if that solves the problem.
Many thanks in advance.