Add a background image

Hello there !

I am a beginner in plotly (very nice package by the way, thank you very much for this great job) and I am completely stuck on a very simple problem.

I try to embed a logo in my graph as here ( When I take the example of this web page everything works correctly.

However, when I change the source of my image from a local image, no background is printed. I think that I have not correctly set up the parameters of my image layout but I cannot figure out how !!

I tried to look on the similar topics ( , but I still don’t find my answer.

Here is my code:


outfile <- tempfile(fileext = ".png")

plot(rnorm(200), rnorm(200))

plot_ly(x = c(1, 2, 3), y = c(1, 2, 3)) %>%
    images = list(
        source =  outfile,
        xref = "x",
        yref = "y",
        x = 1,
        y = 1,
        sizex = 2,
        sizey = 2,
        sizing = "stretch",
        opacity = 0.4,
        layer = "below"


Does anyone have an idea why it is not working?

Thank you very much in advance !!


Hi @boubchat,
I think that’s due to the fact that Plotly requires the image to be in an https address. It hasn’t worked for me with local files either.
Easiest way of solving this is creating a github account and having a public repo where you store the images you want to use.