Show Sidebar Hide Sidebar

Embedding Logos in Plotly Graphs in R

How to embed logos and images into Plotly charts.

New to Plotly?

Plotly's R library is free and open source!
Get started by downloading the client and reading the primer.
You can set up Plotly to work in online or offline mode.
We also have a quick-reference cheatsheet (new!) to help you get started!

Version Check

Version 4 of Plotly's R package is now available!
Check out this post for more information on breaking changes and new features available in this version.

library(plotly)
packageVersion('plotly')
## [1] '4.5.2'

Embed Logos on a Graph

library(plotly)

p <- plot_ly(x = c(1, 2, 3), y = c(1, 2, 3)) %>%
  add_lines() %>%
  layout(
    images = list(
      list(source = "https://images.plot.ly/language-icons/api-home/python-logo.png",
           xref = "paper",
           yref = "paper",
           x= 0,
           y= 1,
           sizex = 0.2,
           sizey = 0.2,
           opacity = 0.8
      ),

      list(source = "https://images.plot.ly/language-icons/api-home/matlab-logo.png",
           xref = "x",
           yref = "paper",
           x = 2.7,
           y = 0.25,
           sizex = 0.4,
           sizey = 0.8,
           opacity = 0.8
      ),

      list(source =  "https://images.plot.ly/language-icons/api-home/r-logo.png",
           xref = "x",
           yref = "y",
           x = 0.9,
           y = 3.1,
           sizex = 2,
           sizey = 2,
           sizing = "stretch",
           opacity = 0.4,
           layer = "below"
      )
    )
  )

# Create a shareable link to your chart
# Set up API credentials: https://plot.ly/r/getting-started
chart_link = plotly_POST(p, filename="logos/1")
chart_link
Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to a Developer Support Plan.