Cannot have more than one shape after subplot()
Nessuno ha ancora preso questa issue.
- Lingua principale
- R
- Stelle
- 2.7k
- Fork
- 641
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
I guess this is related to #1333
Here is the issue: it doesn't seem possible to have more than one shape after subplot() is called. Applying the shapes to the individual plots work, though.
reprex that works:
library(plotly)
p1 <- plot_ly(mtcars, x = ~mpg, y = ~hp) %>%
layout(
shapes = list(
list(
type = "line",
line = list(color = "#5681c4", dash = "dot"),
x0 = 20,
x1 = 20,
y0 = 0,
y1 = 1,
yref = "paper"
),
list(
type = "line",
line = list(color = "#5681c4", dash = "solid"),
x0 = 30,
x1 = 30,
y0 = 0,
y1 = 1,
yref = "paper"
)
)
) %>%
config(editable = TRUE)
p2 <- plot_ly(mtcars, x = ~mpg, y = ~drat) %>%
layout(
shapes = list(
list(
type = "line",
line = list(color = "#5681c4", dash = "dot"),
x0 = 20,
x1 = 20,
y0 = 0,
y1 = 1,
yref = "paper"
),
list(
type = "line",
line = list(color = "#5681c4", dash = "solid"),
x0 = 30,
x1 = 30,
y0 = 0,
y1 = 1,
yref = "paper"
)
)
) %>%
config(editable = TRUE)
subplot(p1, p2, nrows = 2)
reprex that does not work:
library(plotly)
p1 <- plot_ly(mtcars, x = ~mpg, y = ~hp)
p2 <- plot_ly(mtcars, x = ~mpg, y = ~drat)
subplot(p1, p2, nrows = 2) %>%
layout(
shapes = list(
list(
type = "line",
line = list(color = "#5681c4", dash = "dot"),
x0 = 20,
x1 = 20,
y0 = 0,
y1 = 1,
yref = "paper"
),
list(
type = "line",
line = list(color = "#5681c4", dash = "solid"),
x0 = 30,
x1 = 30,
y0 = 0,
y1 = 1,
yref = "paper"
)
)
) %>%
config(editable = TRUE)
reprex with only one shape - it works:
library(plotly)
p1 <- plot_ly(mtcars, x = ~mpg, y = ~hp)
p2 <- plot_ly(mtcars, x = ~mpg, y = ~drat)
subplot(p1, p2, nrows = 2) %>%
layout(
shapes = list(
type = "line",
line = list(color = "#5681c4", dash = "dot"),
x0 = 20,
x1 = 20,
y0 = 0,
y1 = 1,
yref = "paper"
)
) %>%
config(editable = TRUE)
Any thoughts?
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo i reprex funzionanti e quelli che falliscono nell’issue, confrontando le shapes fornite a ciascun plot con le shapes aggiunte dopo subplot(). Traccia il modo in cui subplot() combina i plot e in cui viene gestita la chiamata successiva a layout(shapes = ...). Il lavoro è completo quando entrambe le shapes vengono renderizzate nel subplot e rimangono modificabili con config(editable = TRUE).
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- r
- Ambito
- data-visualization
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100