matplotlib / matplotlib/ipympl

figure changes size at end of loop if drawn dynamically

Open
#17 15 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
1.7k
Forks
234
PR merge metrics
No merged PRs in 30d

Description

As per the title, consider the following snippet:

```
import time
import ipympl
import matplotlib.pyplot as plt

fig, ax = plt.subplots(1, 1, figsize=(5, 5))
data = []
plt.show()
for idx in range(4):
data.append(idx ** 2)
ax.clear()
ax.plot(data)
fig.canvas.draw()
time.sleep(0.2)
```
and this is what I get running it:

![gyrodown](https://user-images.githubusercontent.com/10957113/29539221-e06d9f78-86c0-11e7-9894-2d33623bee86.gif)

I used `plt.show()` at the beginning of the loop because nothing gets drawn otherwise.
Is there a way to avoid this?

Contributor guide

Open the contributing guide

Research direction

Start by running the provided Python snippet in a Jupyter Notebook with ipympl and observe the figure resizing during the loop. Trace the dynamic draw behavior used by the example, then verify that the figure keeps its intended size across all four updates.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, matplotlib, python
Domain
data-visualization, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.