plotly / plotly/plotly.py

constraining axes leads to paper coordinates being off and to extra space between plot area and annotations

Abierto
#4,872 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

bug P2
Lenguaje dominante
Python
Estrellas
18.8k
Forks
2.8k
Merge medio
16 h 26 min
PR fusionados (30 d)
21

Descripción

If I constrain the x-axis, a legend to the right of the plot area shows up too far to the right and paper coordinates x=0 and x=1 are no longer at the edges of the plot area. Paper coordinate x=1 should always be the right edge of the plot area. There should not be excessive trapped white space between the legend and the plot area. The constrained, no-width behavior should be similar to the unconstrained and constrained-with-width behaviors.

Here I reproduce the problem using the documentation example here:
https://plotly.com/python/axes/#fixed-ratio-axes

I'm happy to provide and diff the output JSON if that would be helpful

import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(go.Scatter(
    x = [0,1,1,0,0,1,1,2,2,3,3,2,2,3],
    y = [0,0,1,1,3,3,2,2,3,3,1,1,0,0],
    name="demo"
))

##Add some elements outside the main plot area
fig.update_layout(
        title=dict(text="Source:  Plotly Bug Report",
                   yref="container",
                   xref="paper",
                   xanchor="right",
                  x=1, y=0.005),
                  showlegend=True
)


#the current layout is reasonable -- the legend is close to the plot area and x=1 in paper coordinates is where we expect it.
fig.show()

#now we constrain the domain and it injects lots of space between the plot area and the legend
#paper coordinates no longer reference the plot area -- paper coordinate x=1 is well to the right of the plot area
fig.update_xaxes(
    range=[-1,4],  # sets the range of xaxis
    constrain="domain",  # meanwhile compresses the xaxis by decreasing its "domain"
)
fig.update_yaxes(
    scaleanchor = "x",
    scaleratio = 1
)

fig.show()

#now we specify the width and the layout becomes reasonable again

fig.update_layout(
    width = 800,
)

fig.show()

unconstrained graphic (expected behavior):
Image
constrained graphic (unexpected behavior)
Image
constrained graphic with width (expected behavior)
Image

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con el ejemplo de ejes de proporción fija en la página de documentación enlazada y ejecuta las tres variantes de diseño mostradas en el informe. Compara el resultado restringido sin ancho con los resultados sin restricciones y con ancho explícito; se considera terminado cuando paper x=1 se alinea con el borde derecho del área del gráfico y no queda espacio excesivo entre el gráfico y la leyenda o las anotaciones.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Á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
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.