# Closing python matplotlib window not possible

**URL:** https://discourse.slicer.org/t/closing-python-matplotlib-window-not-possible/10638
**Category:** Development
**Created:** [March 11, 2020, 12:01pm UTC](https://discourse.slicer.org/t/closing-python-matplotlib-window-not-possible/10638 "2020-03-11T12:01:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rprueckl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rprueckl/32/4240_2.png) [@rprueckl](https://discourse.slicer.org/u/rprueckl)
#### Post date: [March 11, 2020, 12:01pm UTC](https://discourse.slicer.org/t/closing-python-matplotlib-window-not-possible/10638/1 "2020-03-11T12:01:28Z")

</div>

Hi, I create (for quick testing and prototyping) some matplotlib windows from my segmenteditor effect (in the callback of the apply button) like described here:

> [@Use full power of Python in Slicer](https://discourse.slicer.org/t/use-full-power-of-python-in-slicer/7162/5):
>
> I’ve just tried interactive plotting using matplotlib and it works fine for me on Windows. I just had to switch to WXAgg backend. Setup: pip\_install("matplotlib wxPython") Example interactive plot using matplotlib: # Get a volume from SampleData and compute its histogram import SampleData import numpy as np volumeNode = SampleData.SampleDataLogic().downloadMRHead() histogram = np.histogram(arrayFromVolume(volumeNode), bins=50) # Set matplotlib to use WXAgg backend import matplotlib matplotl…

Unfortunately, it is not possible to close the window after use. Any ideas why this happens? Thanks.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [March 11, 2020, 12:37pm UTC](https://discourse.slicer.org/t/closing-python-matplotlib-window-not-possible/10638/2 "2020-03-11T12:37:25Z")

</div>

You can find various ways of plotting using matplotlib here: [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Using\_matplotlib](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Using_matplotlib) (including rendering in a static qt window, which can be surely closed without problems).
