Ggplot2: Difference between revisions
| (One intermediate revision by the same user not shown) | |||
| Line 38: | Line 38: | ||
For embedding in a latex file, I recommend exporting as PDF. This allows exporting as a vector format with text. | For embedding in a latex file, I recommend exporting as PDF. This allows exporting as a vector format with text. | ||
If you must export as a raster image (jpeg, png), set the dpi flag to get a high-resolution image. | If you must export as a raster image (jpeg, png), set the dpi flag to get a high-resolution image. | ||
Note that embed fonts requires ghostscript: | |||
<pre> | |||
apt-get install ghostscript -y | |||
</pre> | |||
===Legends=== | |||
[https://ggplot2.tidyverse.org/articles/articles/faq-customising.html?q=legend#legends Customizing FAQ]<br> | |||
[https://ggplot2.tidyverse.org/reference/guide_legend.html guide_legend] | |||
<syntaxhighlight lang="R"> | |||
# Move legend to the bottom | |||
plot <- plot + theme(legend.position = "bottom") | |||
# Set color legend to have two rows | |||
plot <- plot + guides(color=guide_legend(nrow=2, byrow=TRUE)) | |||
</syntaxhighlight> | |||