Nicola Pasquino Nicola Pasquino - 1 year ago 123
R Question

Change label of gganimate frame title

Skimming through the options of

that can be set when
is called to render the animated sequence, it seems that there is no option to change the frame title so to make it clearer to the observer of what is the parameter that the frame is based on.

In other words, suppose that
frame = year
in a layer: how do I make the frame's title be
year: ####
where #### is the year of the current frame? Am I missing something or is it a limitation of the

How would you achieve the same result by a workaround?
Thanks for your advice.

Answer Source

The frame's subset value is appended to any pre-existing title. You can therefore add a title with explanatory text. For example:


p=ggplot(mtcars, aes(wt,mpg, frame=cyl)) + geom_point() + 
    ggtitle("Cylinders: ")


As you can see in the GIF below, the prefix "Cylinders: " is now added to the title before the value of cyl:

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download