0

我有一个情节,然后我更改了一些默认属性,ggplot例如font face, font color, bold等。但是,当我使用命令或从Rstudio's plot图像打开情节时,包含我所有的自定义属性。

但是,当我使用ggsave它保存绘图时,不会显示和保存图像的所有自定义属性。更具体地说,我保存的图像未显示them().

我的代码如下

plot <- ggplot(plot_df, aes(Region, diff, fill = Region))+
  geom_bar(stat = "identity", width = 0.8, position = position_dodge(width = 0.9))+
  theme_bw()+
  
  theme(panel.grid = element_blank(),
        plot.title = element_text(color = "black", face = "bold"),
        axis.text.x = element_text(colour="black",size=10,face="bold"),
        axis.text.y = element_text(colour="black",size=10,face="bold")
  )+
  xlab("Region")+
  ylab("Average Region Rainfall (mm)")+
  ggtitle("Average Region Ranfall") 

使用保存代码ggsave

ggsave("~/My/plot.png", plot = plot+
         theme_bw(base_size = 10, base_family = "Times New Roman"), width = 10, height = 8, dpi = 150, units = "in", device='png')

有没有办法使用ggsave保存原始情节?

4

1 回答 1

0

只需更改theme_bw(). theme()希望这会奏效。

ggsave("~/My/plot.png", plot = plot+
         theme(), width = 10, height = 8, dpi = 150, units = "in", device='png')
于 2020-10-21T20:16:10.503 回答