I'm coding in Rmarkdown and I prefered to change the font type of my plots using the following code:
windowsFonts(timesnewroman = windowsFont("Times New Roman"))
and in a ggplot plot adding:
... + theme(text = element_text(family = "timesnewroman"))
When I then open the plot using "Show in new window" button the font changes to the default font as it is in R plots in normal. How can I avoid this change? Because when I open it in a new window I take a screenhot of the plot and use it in my report, so I don't wanted that the font type changed to the default. What can I do? :/
So, based on the answer given by @user2554330 the following worked for me:
library(cowplot) # use this library to use the plot_grid function
# saving the plot as an image with the prefered size
png(filename="my working directory/myplot.png", width=850, height=450)
plot_grid(plot1, plot2, labels = c("A", "B"),
ncol=2, nrow=1,
label_x=0.45,
label_y=1.040,
label_size=13)
dev.off()
Using these codes the image with the size of I want is saved into my folder/working directory.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.