DiscoR
DiscoR

Reputation: 247

Increasing the font size of a title in a gganimate plot?

I would simply like to increase the font size of the title for a gganimate object. I used the following code but it didnt change the size of the title. I changed the title font using theme.

Libraries

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

Example Data

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))

Example Code

 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)

Thanks for reading!

Upvotes: 1

Views: 1087

Answers (1)

DiscoR
DiscoR

Reputation: 247

I an answered my own question. Never mind, theme(plot.title = element_text(size = 20, face = "bold")) is working! Made a mistake earlier in printing the graph.

Upvotes: 2

Related Questions