1

我只想增加 gganimate 对象的标题字体大小。我使用了以下代码,但它没有改变标题的大小。我使用 . 更改了标题字体theme

图书馆

library(ggplot2)
library(gganimate)
library(ggpubr)

示例数据

structure(list(subject = c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L
), treatment = c("a", "a", "a", "b", "b", "b", "a", "a", "a"), 
    time = c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L), outcome1 = c(80L, 
    75L, 74L, 90L, 81L, 76L, 90L, 89L, 87L), outcome2 = c(15L, 
    14L, 12L, 16L, 15L, 15L, 17L, 14L, 12L)), class = "data.frame", row.names = c(NA, 
-9L))

示例代码

 ggplot(dat2, aes(x=treatment, y=outcome1, fill=treatment)) + 
  geom_violin() +
  guides(fill = FALSE) +
  scale_fill_manual(values=c("#00AFBB", "#FC4E07")) +
  stat_compare_means(aes(label = ..p.format..), paired = FALSE, label.x.npc = 0.5) +
  theme(plot.title = element_text(size = 20, face = "bold")) +
  labs(title = 'Week: {frame_time}', x = 'Diet', y = 'Outcome1 (mm)') +
  transition_time(time) +
  ease_aes('linear')
animate(p1, duration = 12, fps = 1)

谢谢阅读!

4

1 回答 1

1

我回答了我自己的问题。没关系,theme(plot.title = element_text(size = 20, face = "bold"))正在工作!之前在打印图表时犯了一个错误。

于 2018-12-05T18:40:26.867 回答