When trying to create data plots that are not inlined in a notebook, there is some erroneous behaviour. Either the error described here happens, or the plots are shown and a crash report dialog pops up.

This happens with the following setup:

macOS Monterey 12.1

Python: 3.9.1

matplotlib: 3.5.0

Jupyter: 1.0.0

notebook: 6.4.7

(using a virtual environment)

**Example 1:**

```
import numpy as np
import matplotlib.pyplot as plt
```

```
%matplotlib osx
```

```
plt.plot(np.arange(100))
```

*This leads to the error described in the stack overflow link mentioned above. The cell with the call to plot() seems to be evaluated repeatedly. Sometimes, a plot window will show but get stuck, due to the repeated calls.*

**Example 2:**

```
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
```

```
matplotlib.use('QtAgg')
```

```
plt.plot(np.arange(100))
```

*This runs through smoothly, except for the fact that no plot is shown. The last cellâ€™s call returns [<matplotlib.lines.Line2D at 0x12f076bf1>] though. Adding plt.show() does not help either. With TkAgg backend, the same behaviour is observed. Interestingly, when using MacOSX as a backend, I would expect, that the error from Example 1 would occur, but the behaviour is the same as with the other backendsâ€¦*

How can I plot my data externally to the notebook without any errors under the conditions described above? Please help!