Line graph - how to animate one line while keeping the other line static?

Hi! I'm trying to make an animated line graph to model ecosystem biomass, but I want to have one line (variable) move while the other line (the other variable) is static in the background.
my data frames are taken from an excel sheet using the readxlpackage. I have two excel sheets both with an x and y variable, but the x variable on both sheets is the same (biomass).

I set the data from the excel sheets into data frames.

ydf <- data.frame(weight)
y2df <- data.frame (height)

Then I used the code below to create a graph with two sets of y-variables sharing the same x-variable. I was able to create a line graph that had both y-varibales graphed with the same x-variable. Then I tried to animate the plot to have only the "weight" variable move and to keep the "height" variable static :

  geom_line(data = ydf, aes(y = weight), color = "green") +
  geom_line(data = y2df, aes (y = height), color = "dark green") + 
  labs(x = "Biomass", y = "size") + 
  scale_x_reverse (breaks = c(100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0)) + 
  scale_y_continuous (breaks = c(0.00, 0.50, 1.00, 1.50, 2.00, 2.50, 3.00, 3.50, 4.00)) +
  theme(legend.position="none")
q1_gif <- q1+ geom_line (data = ydf, aes(y = weight)) +
  transition_reveal(biomass, range = c(100,0), keep_last = FALSE)
q1_gif

This still resulted in both y-variables being animated. Does anyone know how to change the code so that one variable is animated, but the other variable stays static? I would really appreciate your help!

Here is what my excel sheet data looks like also:
My excel sheet looks something like this:
biomass vs weight (y = weight, x = biomass)
image

biomass vs height (y = height, x = biomass)
image

Sorry for the multiple replies, I could only put one embedded item in each post.

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.