plotly / plotly/plotly.py

Adding secondary-y latex legend name shifts x-axis coordinates

Aperta
#4,588 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug P3 sev-3
Lingua principale
Python
Stelle
18.8k
Fork
2.8k
Merge medio
16h 26m
PR unite (30g)
21

Descrizione

Plotly version 5.20.0.

I am creating subplots with seconary y-axes. When I add the name attribute to a figure that includes a Latex string, the x-axis coordinates are incrementally shifted more and more to the right with each subplot. For instance, the first subplot in this image renders fine, but 2 through 4 are shifted right:

newplot (26)

This only happens when including the Latex string.

Here's a minimal working example:

import plotly.graph_objects as go
from plotly.subplots import make_subplots

x = [1, 2, 3, 4]
y = [1]*4

R = 1
C = 4

fig = make_subplots(
    rows=R,
    cols=C,
    specs=[
        [{"secondary_y": True} for _ in range(C)]
        for _ in range(R)
    ],
)

rc = [(r, c) for r in range(R) for c in range(C)]

for i, (r, c) in enumerate(rc):
    fig.add_trace(
        go.Scatter(
            x=x,
            y=y,
            showlegend=not i,
            name="y1",
        ),
        row=r+1,
        col=c+1,
        secondary_y=False,
    )
    fig.add_trace(
        go.Scatter(
            x=x,
            y=y,
            showlegend=not i,
            name=r"$y$2",
        ),
        row=r+1,
        col=c+1,
        secondary_y=False,
    )



Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Eseguire l’esempio minimo funzionante fornito con quattro subplots e confrontare il rendering con e senza il nome della legenda in LaTeX. Tracciare il modo in cui vengono calcolate le coordinate dell’asse x dei subplots durante il rendering, quindi verificare che tutte le posizioni dei subplots rimangano allineate quando il trace dell’asse secondario utilizza l’etichetta LaTeX.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.