我只想增加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)
感谢阅读!
答案 0 :(得分:1)
我回答了我自己的问题。没关系,theme(plot.title = element_text(size = 20, face = "bold"))
在工作!先前在打印图形时犯了一个错误。