Plotting data only on secondary_y axes ignores subplot grid
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 18.8k
- Forks
- 2.8k
- Merge medio
- 16 h 26 min
- PR fusionados (30 d)
- 21
Descripción
Hello,
running the following code will produce a 2x2 subplot grid with data on the primary_y axes and data on one secondary_y axes.
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import numpy as np
rows = 2
cols = 2
fig = make_subplots(rows=rows, cols=cols, specs=[[{"secondary_y": True}] * cols] * rows)
fig.add_trace(go.Scatter(x=np.arange(5), y=np.arange(5), name='1:1 primary_y',),
secondary_y=False, row=1, col=1)
fig.add_trace(go.Scatter(x=np.arange(5), y=np.arange(5), name=f'1:2 primary_y',),
secondary_y=False, row=1, col=2)
fig.add_trace(go.Scatter(x=np.arange(5), y=np.arange(5), name=f'2:1 primary_y',),
secondary_y=False, row=2, col=1)
fig.add_trace(go.Scatter(x=np.arange(5), y=np.arange(5), name=f'2:2 primary_y',),
secondary_y=False, row=2, col=2)
# plot on secondary_y
fig.add_trace(go.Scatter(x=np.arange(5) + 1, y=np.arange(5), name=f'2:2 secondary_y',),
secondary_y=True, row=2, col=2)
fig.update_layout(height=400, width=600)
fig.write_html('test_bug.html')
however if you don’t plot any data on a primary_y axes but leave the data on the secondary_y axes the height of the axes will take up the whole height of the figure
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import numpy as np
rows = 2
cols = 2
fig = make_subplots(rows=rows, cols=cols, specs=[[{"secondary_y": True}] * cols] * rows)
fig.add_trace(go.Scatter(x=np.arange(5), y=np.arange(5), name='1:1 primary_y',),
secondary_y=False, row=1, col=1)
fig.add_trace(go.Scatter(x=np.arange(5), y=np.arange(5), name=f'1:2 primary_y',),
secondary_y=False, row=1, col=2)
fig.add_trace(go.Scatter(x=np.arange(5), y=np.arange(5), name=f'2:1 primary_y',),
secondary_y=False, row=2, col=1)
# fig.add_trace(go.Scatter(x=np.arange(5), y=np.arange(5), name=f'2:2 primary_y',),
# secondary_y=False, row=2, col=2)
# plot on secondary_y
fig.add_trace(go.Scatter(x=np.arange(5) + 1, y=np.arange(5), name=f'2:2 secondary_y',),
secondary_y=True, row=2, col=2)
fig.update_layout(height=400, width=600)
fig.write_html('test_bug.html')
is this behaviour intentional?
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
Reproduce los dos ejemplos usando make_subplots, add_trace y la opción secondary_y, comparando los archivos test_bug.html generados. Investiga cómo la cuadrícula de subplots asigna los dominios de los ejes cuando se omite el trace primario de la fila 2, columna 2. Se considera terminado cuando los datos que solo usan el eje secundario permanecen confinados a su celda de subplot de 2x2 en lugar de expandirse por toda la figura.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- numpy, python
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100