Plotly unable to embed a logo or background image in plotly

I have tried to plot an image behind my plot and failed. I then tried to do this : which also failed. Any clue as to what is going wrong?

Can you be more specific about what failed?

If I had to guess, you must be using an older version of the plotly R package.

The code did run but only the graph without the background image was displayed.

1 Like

Is the code mentioned in the above link working? I tried running it, but not working

I am also facing the same issue. The code provided in somehow does not work for me.

Can you specified what version of the plotly R package you are using?

I am using the latest version 3.6.0

Using the same as ysingh mentioned. Version 3.6.0

Etienne is the code mentioned in the link running in your machine?

Does anyone have any suggestions?


I’m temporarily plotting graphs in python for my project. rPython package might interest you.

Hi @savitaluri,
Did you manage to get this to work?
I’m facing the same problem. I can see the logo when I run the app locally on R Studio, but when I publish to a server and access the app through the browser the logo doesn’t show.

I came to understand that, it was a problem with the path. Give the
relative path in the server.R. That solved the problem in my case. Please
share your code if you need any help further.

1 Like

Can a reproducible example be added? That would really help. I’m having the same issue and it’s 2018. I’ve updated all the packages to the newest versions, installed RStudio, and R build tools, and the development versions of plotly and ggplot2. It still does not work, even after pasting the example above.

@jamesdalg : Please share your code. I can help correct that. Also, please run the sessionInfo() command in R, and paste the output.

p <- plot_ly(x = c(1, 2, 3), y = c(1, 2, 3)) %>%

  • add_lines() %>%
  • layout(
  • images = list(
  •   list(source = "",
  •        xref = "paper",
  •        yref = "paper",
  •        x= 0,
  •        y= 1,
  •        sizex = 0.2,
  •        sizey = 0.2,
  •        opacity = 0.8
  •   ),
  •   list(source = "",
  •        xref = "x",
  •        yref = "paper",
  •        x = 2.7,
  •        y = 0.25,
  •        sizex = 0.4,
  •        sizey = 0.8,
  •        opacity = 0.8
  •   ),
  •   list(source =  "",
  •        xref = "x",
  •        yref = "y",
  •        x = 0.9,
  •        y = 3.1,
  •        sizex = 2,
  •        sizey = 2,
  •        sizing = "stretch",
  •        opacity = 0.4,
  •        layer = "below"
  •   )
  • )
  • )

R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] bindrcpp_0.2 plotly_4.7.1.9000 Cairo_1.5-9 ggplot2_2.2.1.9000 miniUI_0.1.1 shiny_1.0.5

loaded via a namespace (and not attached):
[1] Rcpp_0.12.16 pillar_1.2.1 compiler_3.4.4 plyr_1.8.4 bindr_0.1.1 tools_3.4.4 digest_0.6.15 viridisLite_0.3.0 jsonlite_1.5
[10] tibble_1.4.2 gtable_0.2.0 pkgconfig_2.0.1 rlang_0.2.0.9000 crosstalk_1.0.0 yaml_2.1.18 withr_2.1.2 dplyr_0.7.4 httr_1.3.1
[19] htmlwidgets_1.0 grid_3.4.4 glue_1.2.0 data.table_1.10.4-3 R6_2.2.2 tidyr_0.8.0 purrr_0.2.4 magrittr_1.5 scales_0.5.0.9000
[28] htmltools_0.3.6 assertthat_0.2.0 mime_0.5 xtable_1.8-2 colorspace_1.3-2 httpuv_1.3.6.2 labeling_0.3 lazyeval_0.2.1 munsell_0.4.3

It would be a huge deal if you got this to work. I’ve been trying for days and an image is critical to the utility of the plot(I need to add an axis that displays data that only works in picture form, with specific landmarks/regions in the plot).

@jamesdalg : According to :

source : Specifies the URL of the image to be used. The URL must be accessible from the domain where the plot code is run, and can be either relative or absolute.

The problem seems to occur here. For now, any image that can be accessed from web (https images) seem to work fine with the code above. Unfortunately, I don’t think they are supporting local files yet.

Are other plotly plots getting plotted in your RStudio? Try viewing them in your browser instead.

The following code gives the expected output.

p <- plot_ly(x = c(1, 2, 3), y = c(1, 2, 3)) %>%
  add_lines() %>%
    images = list(
      list(source =  "",
           xref = "x",
           yref = "y",
           x = 1,
           y = 3,
           sizex = 2,
           sizey = 2,
           sizing = "stretch",
           opacity = 0.5,
           layer = "below"



Please try by uploading your image to github/imgur and check if your code is running then. No other option seems to working for now. ggplot2 might be an alternate. annotation_custom() is an option I used.

Neither the code example here Embedding Logos in Plotly Graphs | R | Plotly or any of the examples given here work for me. I have no problem plotting the graphs, but the images/logo’s never render.

I really want to put our company branding on our charts. What do I need to do to get this to work?

1 Like

did u get any solution?