| ggsave_unicode | R Documentation |
This function is a wrapper around ggplot2::ggsave() that temporarily
activates the showtext graphics engine before saving. It ensures that
Unicode characters (e.g., Chinese, special symbols) are rendered correctly
in the saved file, regardless of the output format (vector or raster).
ggsave_unicode(plot, filename, ...)
plot |
The ggplot object to save (should be a |
filename |
File name to save the plot. Extension determines the format (e.g., .png, .pdf, .svg). |
... |
Additional arguments passed to |
The function calls showtext::showtext_begin() before saving and
ensures showtext::showtext_end() is called afterwards, even if an
error occurs. It then passes all arguments to ggplot2::ggsave().
Invisibly returns the filename (as ggsave does).
scatter_plot for creating plots that display
correctly, print.unicode_ggplot for automatic display support.
## Not run:
p <- scatter_plot(...)
ggsave_unicode(p, "myplot.png", width = 6, height = 4, dpi = 300)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.