blitting doesn't work - would be useful to speed up graph draw for faster realtime-graphs
Une pull request liée a déjà été fusionnée.
- #19059 par @ianhi — fusionnée
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 32/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- jupyter-notebook, python
- Domaine
- frontend, performance
Piste de recherche
Commencez par reproduire le notebook fourni avec les versions de JupyterLab et d’ipympl indiquées, en comparant fig.canvas.draw() avec le chemin de blitting. Suivez la gestion de copy_from_bbox, restore_region, draw_artist et blit, puis vérifiez que les mises à jour du slider rafraîchissent visiblement le graphique à de meilleures fréquences d’images sans effectuer de draw complet.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
I have the following code in jupyterlab. This allows me to move a slider and update a graph in realtime. However the framerate is quite low (1fps) if I call fig.canvas.draw(). I therefore tried blitting, however it does not seem to affect the graph. Is this supposed to work with ipympl?
Many thanks for your help.
Environment:
Jupyterlab==1.2.6
ipympl==0.5.6
jupyter labextension list:
@ibqn/jupyterlab-codecellbtn v0.1.3 enabled ok
@jupyter-widgets/jupyterlab-manager v1.1.0 enabled ok
@jupyterlab/google-drive v1.0.0 enabled ok
@jupyterlab/toc v1.0.1 enabled ok
jupyter-matplotlib v0.7.2 enabled ok
jupyterlab-plotly v1.5.2 enabled ok
plotlywidget v1.5.2 enabled ok
import pandas as pd, numpy as np
import time
import matplotlib.pyplot as plt
from ipywidgets import interact, interactive, fixed, interact_manual, Layout, VBox, HBox
import ipywidgets as widgets
from itertools import count
%matplotlib widget
blit = False # False works, True doesn't.
plt.close('all')
plt.ioff()
output = widgets.Output(layout={'width': '700px', 'height': '300px'})
fig, axs= plt.subplots(3, 2, figsize=(10, 8), sharex=True)
fig.canvas.header_visible = False
fig.canvas.toolbar_visible = False
for i in range(3):
axs[i,0].set_ylim(-1.5,1.5)
axs[i,0].set_xlim(0,20)
# index giver
x_value = count()
# expanding dataset
x, y = [], []
# initialise dummy data
[x.append(next(x_value)) for i in range(2)]
[y.append([1]*3) for i in range(2)]
# setup desired and actual angle plots
col_names = ['col1', 'col2', 'col3']
ax_df = pd.DataFrame(index=x,columns=col_names, data=y).plot(subplots=True, ax=axs[:,0])
if blit:
bgs = []
for ax in ax_df:
# cache the background
ax_background = fig.canvas.copy_from_bbox(ax.bbox)
bgs.append(ax_background)
fig.canvas.draw() # initial draw required
# monitor framerate
t_start = time.time()
# event handler
def on_value_changed(change):
with output:
next_x = next(x_value) # generate next x axis value
x.append(next_x)
y.append([change.new]*3)
for i in range(3):
if blit:
# update data
line = ax_df[i].get_lines()[0]
line.set_data(x, pd.DataFrame(y).iloc[:,i])
# restore background
fig.canvas.restore_region(bgs[i])
# redraw just the points
ax_df[i].draw_artist(line)
# fill in the axes rectangle
fig.canvas.blit(ax_df[i].bbox)
else:
# update data
ax_df[i].get_lines()[0].set_data(x, pd.DataFrame(y).iloc[:,i])
# rescale view
ax_df[i].autoscale_view(None,'x',None)
ax_df[i].relim()
fig.canvas.flush_events()
if not blit:
fig.canvas.draw() # this slows down framerate, not required for blit
print(f"FPS: {round(next_x/(time.time() - t_start),2)}", end=", ")
sliders = []
int_slider = widgets.FloatSlider(description="test",
min=-1, max=1,
value = 0, continuous_update=True,
orientation="horizontal",
layout=widgets.Layout(width="500px", height="20px"))
int_slider.observe(on_value_changed, names="value")
sliders = widgets.VBox([int_slider, fig.canvas, output])
display(sliders)
- Langage dominant
- Jupyter Notebook
- Étoiles
- 1.7k
- Forks
- 236
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire 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.
Autres issues de matplotlib/ipympl
-
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
matplotlib/ipympl#623 · 1 commentaire ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
matplotlib/ipympl#622 · 13 commentaires ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 42/100
matplotlib/ipympl#612 ·
-
DeprecationWarning: Passing unrecognized arguments to super(Toolbar).__init__().Peut-être pris @pradeep14012004 l’a pris il y a 6 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 45/100
matplotlib/ipympl#611 · 4 commentaires ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 42/100
matplotlib/ipympl#609 · 7 commentaires ·
Toutes les issues de matplotlib/ipympl
Issues similaires
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
yjh051108/dsh-routing-suite#216 ·
-
kind/bug priority/needs-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
bug user-priority/P2
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
t8y2/dbx#11718 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement good first issue
Difficulté 2/5 Une demi-journée Accessibilité débutants 66/100
apache/fineract-consumer-facing#175 ·
Les mainteneurs répondent en général sous 1 jour
-
bug confirmed perf
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
videojs/video.js#9400 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour