# Use full power of Python in Slicer

**URL:** <https://discourse.slicer.org/t/use-full-power-of-python-in-slicer/7162>\
**Category:** Support\
**Tags:** feature\
**Created:** [June 13, 2019, 4:23pm UTC](https://discourse.slicer.org/t/use-full-power-of-python-in-slicer/7162 "2019-06-13T16:23:11Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [June 15, 2019, 4:48am UTC](https://discourse.slicer.org/t/use-full-power-of-python-in-slicer/7162/5 "2019-06-15T04:48:25Z")

</div>

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:

```python
pip_install("matplotlib wxPython")

```

Example interactive plot using matplotlib:

```python
# 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
matplotlib.use('WXAgg')

# Show a plot using matplotlib
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(histogram[1][1:], histogram[0].astype(float))
ax.grid(True)
ax.set_ylim((0, 4e5))
plt.show(block=False)

```

For reference, to create a similar plot using Slicer’s plotting infrastructure:

```python
chartNode = plot(histogram, xColumnIndex = 1)
chartNode.SetYAxisRangeAuto(False)
chartNode.SetYAxisRange(0, 4e5)

```

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/7/d7e295728729990f9c3c1e841f573c16b01d2e26.png)

---

_[View the full topic](https://discourse.slicer.org/t/use-full-power-of-python-in-slicer/7162)._
