constraining axes leads to paper coordinates being off and to extra space between plot area and annotations
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 18.8k
- Forks
- 2.8k
- Merge moyen
- 16 h 26 min
- PR mergées (30 j)
- 21
Description
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):
constrained graphic (unexpected behavior)
constrained graphic with width (expected behavior)
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par l’exemple d’axes à rapport fixe sur la page de documentation liée et exécutez les trois variantes de mise en page présentées dans le rapport. Comparez le résultat contraint sans largeur avec les résultats non contraint et à largeur explicite ; c’est terminé lorsque paper x=1 est aligné sur le bord droit de la zone du graphique et qu’il ne reste pas d’espace excessif entre le graphique et la légende ou les annotations.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- 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