plotly / plotly/plotly.py

Polar and polar subplot (make_subplots) not displaying correctly in FigureWidget Jupyter Ipython notebook

Ouverte
#1,753 3 commentaires 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

bug P3
Langage dominant
Python
Étoiles
18.8k
Forks
2.8k
Merge moyen
16 h 26 min
PR mergées (30 j)
21

Description

plotly==4.1.1
jupyter==1.0.0
ipython==7.8.0

Plotting a polar in a subplot works fine (#758 resolved in 4.1.1?) but wrapping a polar figure in a FigureWidget and using display causes theta values to become very strange, scattering the data. This happens for subplots and solo polar plots.
This would appear to be a Bug. Any thoughts on a workaround?

import plotly
import plotly.graph_objs as go
import numpy as np
from plotly.subplots import make_subplots

# Data
# the first subplot: a histogram (If using)
trace1 = go.Histogram(
    x=np.random.uniform(1,6,size=62),
)

# the second subplot: a polar graph
trace2 = go.Scatterpolar(
    r = np.random.uniform(1,6,size=62),
    theta = np.random.uniform(30,5,size=62),
    mode='markers',
)

# # # # # # # # # # # # # # # # # # 
# single polar example
# # # # # # # # # # # # # # # # # # 
fig = go.Figure(
    trace2, 
    layout=go.Layout(
        title=go.layout.Title(text="Polar chart - normal fig.show()")
    )
)

fig.show()

# Now wrap in a figure widget and use same traces
# not working correctly

fig.update_layout(go.Layout(
    title=go.layout.Title(text="Polar chart - FigureWidget")
    )
)
fig2 = go.FigureWidget(
    fig,
)
display(fig2)  # allows traces to be added but displays wrong

print("FigureWidget.show()")
fig2.show()  # This will not be updateable with data - just shows base fig

# # # # # # # # # # # # # # # # # # 
# Subplots example
# # # # # # # # # # # # # # # # # # 
# normal use of make_subplots

# make 2 plots sublplot
fig = make_subplots(rows=1, cols=2, specs=[[{}, {'type': 'polar'}]],)
fig.update_layout(go.Layout(
    title=go.layout.Title(text="Polar chart - normal fig.show()")
    ))

fig.append_trace(trace1, 1, 1)

fig.append_trace(trace2, 1, 2)

fig.show()

# Now wrap in a figure widget and use same traces
# not working correctly                
fig2 = go.FigureWidget(make_subplots(rows=1, cols=2, specs=[[{'type': 'bar'}, {'type': 'polar'}]]))

fig2.update_layout(go.Layout(
    title=go.layout.Title(text="Polar chart - FigureWidget")
    ))

display(fig2)  # allows traces to be added but the polar one displays wrong
print("FigureWidget.show()")
fig2.show()  # This will not be updateable with data - just shows base fig

# the first subplot: a histogram
fig2.append_trace(trace1, 1, 1)

# the second subplot: a polar graph
fig2.append_trace(trace2, 1, 2)
                  
print("FigureWidget.show()")
fig2.show() # This fig show will work and display correct data

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par exécuter le reproducer fourni avec les versions indiquées de Python, Jupyter et IPython, en comparant la sortie normale de fig.show() avec display() de FigureWidget, à la fois pour le cas autonome et pour le cas avec des subplots. Le travail est considéré comme terminé lorsque les valeurs theta polaires s’affichent correctement dans les deux scénarios FigureWidget ; l’issue ne nomme au départ aucun fichier source ni aucun test.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
jupyter, jupyter-notebook, 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

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.