Automatic theming in gganimate using thematic package

Hello everyone, I'm currently learning shiny and I stumbled upon the thematic package, which automatically styles plot outputs in Shiny.

I've been trying to use it to automatically style gganimate plots too, without success, so I'm asking for help here, because I think that it is not even possible. This is a reprex, which shows a static plot automatically styled, and a image output with the animation without styling:


ui <- fluidPage(
    theme = shinythemes::shinytheme("sandstone"),

server <- function(input, output) {
    base_plot <- ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
                    geom_line() +
                    labs(title = "Title placeholder")
    output$static <- renderPlot({
    }, res = 96)
    output$dynamic <- renderImage({
        dynamic_plot <- base_plot +
        outfile <- tempfile(fileext = ".gif")
                               renderer = gganimate::gifski_renderer(),
                               res = 96))
        list(src = "outfile.gif",
             contentType = "image/gif")
    }, deleteFile = TRUE)

thematic::thematic_shiny(font = "auto")
shinyApp(ui = ui, server = server)

I tried reading the thematic package documentation too, but couldn't find a way to do what I want.

Thanks in advance!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

I hadn't really considered gganimate -- would you mind filing an issue here?

Also, I'm pretty sure that renderPlot() is working fine, but it's not leading to a noticeable difference because the main colors and fonts of the sandstone theme is not noticeable different from the default. If you to change "sandstone" to "cyborg" the difference will be more obvious.

Thanks, gganimate support is now in the development version of thematic (CRAN release coming soon) remotes::install_github("rstudio/thematic")

1 Like