plotly / plotly/plotly.R

Adding logo to a plot using `layout` doesn't work with local images.

Offen
#2,269 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
R
Sterne
2.7k
Forks
641
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem im Issue gezeigten Einstiegspunkt layout(images = ...) und vergleiche, wie seine Remote-URL und lokale Bildquelle behandelt werden. Reproduziere das Beispiel mit der heruntergeladenen python-logo.png; abgeschlossen ist es, wenn das lokale Bild im Plot so erscheint wie das Remote-Bild.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
r
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.