plotly / plotly/plotly.R

category axis and shapes not playing well when data representing numbers and xref = "x"

Ouverte
#2,324 0 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

Providing a list of strings representing numbers for category axis converts them to number rather than keeping them as strings.
This for me results in the inability to use shapes to shade part of the graph.

Example of what is not working:

newplot (6)

library(plotly)

# Sample data
x <- c("1234", "2345", "3456", "4567")
y <- c(10, 15, 8, 12)

# Create a Plotly chart with a bar plot
fig <- plot_ly(x = ~x, y = ~y)

# Define a rectangle shape
shapes <- list(
  list(
    type = "rect",
    line = list(color = "red"),
    x0 = "1234", x1 = "2345",
    y0 = 0, y1 = 1,
    xref = "x",
    yref = "paper"
  )
)

# Add the rectangle shape to the layout
fig <- fig %>% layout(
  title = 'Highlighting with Lines', 
  xaxis = list(
    type = 'category',
    autotypenumbers = 'strict'
  ),
  shapes = shapes
)

# Display the chart
fig

Example of what is working:

newplot (7)

library(plotly)

# Sample data
x <- c("#1234", "#2345", "#3456", "#4567")
y <- c(10, 15, 8, 12)

# Create a Plotly chart with a bar plot
fig <- plot_ly(x = ~x, y = ~y)

# Define a rectangle shape
shapes <- list(
  list(
    type = "rect",
    line = list(color = "red"),
    x0 = "#1234", x1 = "#2345",
    y0 = 0, y1 = 1,
    xref = "x",
    yref = "paper"
  )
)

# Add the rectangle shape to the layout
fig <- fig %>% layout(
  title = 'Highlighting with Lines', 
  xaxis = list(
    type = 'category',
    autotypenumbers = 'strict'
  ),
  shapes = shapes
)

# Display the chart
fig

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 la reproduction R fournie avec plot_ly() et layout(), en comparant les libellés de catégories à l’apparence numérique avec les libellés fonctionnels précédés de '#'. Suivez la manière dont xaxis type='category' et autotypenumbers='strict' sont traités à la fois pour les données de barres et pour les shapes avec xref='x' ; le résultat attendu est que les chaînes à l’apparence numérique restent catégorielles et que le rectangle couvre les catégories prévues.

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
45/100

Recevez les nouvelles issues par e-mail

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