Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gganimate ignores font face in theme() #504

Open
danm0nster opened this issue Nov 18, 2024 · 0 comments
Open

gganimate ignores font face in theme() #504

danm0nster opened this issue Nov 18, 2024 · 0 comments

Comments

@danm0nster
Copy link

danm0nster commented Nov 18, 2024

Thanks for a wonderful package! I think I found a bug, but, of course, it could also just be me doing something wrong.

Description of the issue: When adding animations to a plot where the fonts have been changed from the default, gganimate seems to ignore face = "italic" in the call to theme().

Minimal reproducible example: Below is a code snippet with a base plot where x and y labels are correctly italicised, but adding an animation changes the label font face to normal.

library(ggplot2)
library(gganimate)

base_plot <- ggplot(
  data.frame(x = c(1, 4), y = c(4, 1)),
  aes(x = x, y = y)
) +
  geom_point() +
  expand_limits(x = c(0, 5), y = c(0, 5)) +
  coord_fixed(ratio = 1) +
  theme_classic() +
  theme(
    axis.text = element_text(size = 12, family = "Helvetica", face = "plain"),
    axis.title.x = element_text(size = 16, family = "Times", face = "italic", hjust = 1),
    axis.title.y = element_text(size = 16, family = "Times", face = "italic", angle = 0)
  )

plot(base_plot)
ggsave("base_plot.png")

base_plot +
  transition_reveal(x)
anim_save("animation_plot.gif")

Output: The two plots are shown below.

base_plot

animation_plot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant