plotly.R
plotly.R copied to clipboard
Adding logo to a plot using `layout` doesn't work with local images.
It appears that if you add a logo to a plotly figure using the layout function, it only works when using a remotely hosted image. Using the example on the logo tutorial, the logo is added to the plot if you point to a remote url, but not if you point to a local image:
library(plotly)
# photo used in Plotly logo example page
url <- "https://images.plot.ly/language-icons/api-home/python-logo.png"
download.file(url, "./python-logo.png")
fig <- plot_ly(x = c(1, 2, 3), y = c(1, 2, 3))
fig <- fig %>% add_lines()
this_works <- fig %>%
layout(
images = list(
list(source = url,
xref = "paper",
yref = "paper",
x= 0,
y= 1,
sizex = 0.2,
sizey = 0.2,
opacity = 0.8
)
)
)
this_doesnt <- fig %>%
layout(
images = list(
list(source = "./python-logo.png",
xref = "paper",
yref = "paper",
x= 0,
y= 1,
sizex = 0.2,
sizey = 0.2,
opacity = 0.8
)
)
)
Created on 2023-05-23 with reprex v2.0.2