10000 Matplotlib blitting in Jupyter Notebooks (issue #4288) by mbewley · Pull Request #9240 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Matplotlib blitting in Jupyter Notebooks (issue #4288) #9240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
TST: tweak the blitting UAT a bit
Grab the background after the first draw to avoid issue with hi-dpi
screens.
  • Loading branch information
tacaswell committed Feb 10, 2018
commit 0111e12e3d2e5fdbd307f2732e4e21d890bfb228
9 changes: 6 additions & 3 deletions lib/matplotlib/backends/web_backend/nbagg_uat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,16 @@
"import itertools\n",
"\n",
"cnt = itertools.count()\n",
"\n",
"bg = None\n",
"\n",
"def onclick_handle(event):\n",
" \"\"\"Should draw elevating green line on each mouse click\"\"\"\n",
" global bg\n",
" if bg is None:\n",
" bg = ax.figure.canvas.copy_from_bbox(ax.bbox) \n",
" ax.figure.canvas.restore_region(bg)\n",
"\n",
" cur_y = next(cnt) * 0.1\n",
" cur_y = (next(cnt) % 10) * 0.1\n",
" ln.set_ydata([cur_y, cur_y])\n",
" ax.draw_artist(ln)\n",
" ax.figure.canvas.blit(ax.bbox)\n",
Expand All @@ -595,7 +598,7 @@
"ln, = ax.plot([0, 1], [0, 0], 'g', animated=True)\n",
"plt.show()\n",
"ax.figure.canvas.draw()\n",
"bg = ax.figure.canvas.copy_from_bbox(ax.bbox)\n",
"\n",
"ax.figure.canvas.mpl_connect('button_press_event', onclick_handle)"
]
},
Expand Down
0