plotly / plotly/plotly.R

Cannot have more than one shape after subplot()

Ouverte
#1,869 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
R
Étoiles
2.7k
Forks
641
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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?

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par exécuter les reprexes qui fonctionnent et ceux qui échouent dans l’issue, en comparant les shapes fournies à chaque plot avec les shapes ajoutées après subplot(). Suivez la manière dont subplot() combine les plots et dont l’appel ultérieur à layout(shapes = ...) est traité. Le travail est terminé lorsque les deux shapes sont rendues dans le subplot et restent modifiables avec config(editable = TRUE).

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
r
Domaine
data-visualization
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.