I am trying to plot some data from my swim team from the last competitions.
Animated Plot here: https://i.stack.imgur.com/y3FNz.jpg
(1) To improve the visual appearance, I inserted a background image. However this background image somehow overlays the original animation. You can see it in the animation below. This background image already has 70% opacity but i still can't see the animated line properly.
(2) I also tried to animate the coloring of the line in a way that i changes its color during the animation. Meaning something like the line is red while being below the value of 6.5 and turns green when above 6.5 Is that possible at all?
For (1) I tried changing the opacity of the background image but with no success
For (2) I tried to add this to
geom_line() +
scale_colour_gradient(low="coral", high="steelblue") +
but nothing happened (no error message, too)
Full code:
library(ggplot2)
library(gganimate)
library(png)
data <- tibble::tribble(~Heat, ~Performance,
8.1, 5.6,
8.2, 5.9,
8.3, 5.5,
8.4, 6.2,
8.5, 6.8,
8.6, 7.2,
8.7, 7.6,
)
url <- "https://i.imgur.com/mREnnlF.png"
download.file(url, destfile = "background_image.png")
background_image <-readPNG("background_image.png")
p <- ggplot(data, aes(Heat, Performance)) +
geom_line(color='coral', size = 1) +
geom_point(color= "steelblue", size = 3) +
background_image(background_image) +
transition_reveal(Heat) +
ease_aes('cubic-in-out')
animate(p, fps = 10, end_pause=10, width = 800, height = 400)
(a) I am looking to make the animated appear clearly in the front
(b) The change of the line coloring can be either abrupt from the starting color to the next one or a smooth, animated transition. both is fine.
(c) Additionally - if possible - I want to get rid of the y axis description and instead have the values of the datapoints showed in the animation wenn the line reaches each datapoint. so that at the end of the animation, the line is shown together with the respective values at their respective datapoints.
Any help much appreciated & thx in advance to whoever can tackle this! Best Tom