Black Lives Matter. Please consider donating to Black Girls Code today.

When I export my plotly animation the background image is lost

I have searched the forums and internet and have not found a solution to this. I am able to link a background image as a map behind my plotly scatterplot and it looks fine in the R viewer but when I export it the background image is gone. Does anyone know why this is happening and if there is anything I can do about it?

Here is my code:

library(plotly)

df <-read.csv(“https://github.com/angelaRout/test/blob/master/km_join.csv?raw=true”)

test_plotly <- df%>%
plot_ly(x = ~lon_cluster,
y = ~lat_cluster,
type = ‘scatter’,
mode = ‘markers’,
color=~TIME.OF.DAY,
size=~FREQ,
text=~TIME.OF.DAY,
frame=~MONTH,
hoverinfo=“text”,
marker = list(
opacity = 0.7, sizemode = ‘diameter’
)) %>%
layout(
xaxis = list(range = c(-9700, -8680)),
yaxis = list(range = c(5659820,5660570)),
images = list(
list(
source = “https://github.com/angelaRout/test/blob/master/university2.png?raw=true”,
xanchor = “left”,
xref = “x”,
yref = “y”,
x = -9700 ,
y = 5660570,
sizex = 1020,
sizey = 750,
opacity = 0.4,
layer = “below”,
sizing = “stretch”
)
), title = ‘Point Clusters’,
showlegend = TRUE)%>%
config(displayModeBar = F) %>%
animation_opts(
1000, easing = “elastic”, redraw = FALSE
) %>%
animation_button(
x = 1, xanchor = “right”, y = 0, yanchor = “bottom”
) %>%
animation_slider(
currentvalue = list(prefix = "MONTH ", font = list(color=“grey”))
)

test_plotly

htmlwidgets::saveWidget(as_widget(test_plotly) , “test_plotly_plot6.html”)

When I view it in the rStudio viewer it looks like this:

but after I export and open in chrome it is missing the background image:

***EDIT - I was able to relink the image in the Plotly API, and export it as HTML from the plotly API, and it worked.