Have you figured anything out? I’m trying to do the exact same thing with months. I’d prefer it to display the month spelled out instead of just the number. When I use an ordered factor of the month names, it ends up adding a bunch of traces to the chart and there is no animation. Here’s some code I’m working with:
snow_plot <- snow_depth %>% plot_ly(
x = ~year,
y = ~avg_depth,
color = ~avg_temp,
frame = ~month_char,
text = ~paste('<i>Month</i>: ', month_char,
'<br><b>Avg. Depth</b>: ', avg_depth,
'<br><b>Avg. Temp</b>: ', avg_temp),
hoverinfo = 'text',
type = 'bar'
) %>%
layout(
title = "Average Snow Depth by Week",
yaxis = list(title = "Average Depth (mm)")
) %>%
animation_opts(
frame = 1000
)
In this code, month_char is the ordered factor of months using three character abbreviations (e.g., Mar, Apr, May, etc.).