category axis and shapes not playing well when data representing numbers and xref = "x"
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- R
- Estrellas
- 2.7k
- Forks
- 641
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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:
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:
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza ejecutando la reproducción de R proporcionada con plot_ly() y layout(), comparando las etiquetas de categoría con aspecto numérico con las etiquetas que funcionan y llevan '#' como prefijo. Traza cómo se gestionan xaxis type='category' y autotypenumbers='strict' tanto para los datos de barras como para las shapes con xref='x'; el objetivo se cumple cuando las cadenas con aspecto numérico siguen siendo categóricas y el rectángulo abarca las categorías previstas.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- r
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100