# 2D visualization in Slicer (Spectrogram, contour plot)

**URL:** <https://discourse.slicer.org/t/2d-visualization-in-slicer-spectrogram-contour-plot/18727>\
**Category:** Development\
**Created:** [July 14, 2021, 11:02am UTC](https://discourse.slicer.org/t/2d-visualization-in-slicer-spectrogram-contour-plot/18727 "2021-07-14T11:02:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [July 14, 2021, 11:02am UTC](https://discourse.slicer.org/t/2d-visualization-in-slicer-spectrogram-contour-plot/18727/1 "2021-07-14T11:02:07Z")

</div>

Hi,

I’m searching for information about 2D visualization in Slicer. For example I can see this [doc page](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Plots) but I can’t understand what library is used for 2D plotting? Is it VTK?

In near future I have to decide what library to use to display some matrices in form of Spectrogram and contour plot [like in the pictures here](https://qwt.sourceforge.io/spectrogramscreenshots.html)

Previously I had some experience of working with [QWT](https://qwt.sourceforge.io/index.html) library but now when I work with Slicer I think I could replace QWT by some internal Slicer’s visualization library (probably VTK or some other)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 14, 2021, 2:52pm UTC](https://discourse.slicer.org/t/2d-visualization-in-slicer-spectrogram-contour-plot/18727/2 "2021-07-14T14:52:16Z")

</div>

Yes, Plotting in Slicer uses VTK (see [Documentation/Nightly/Developers/FAQ - Slicer Wiki](https://www.slicer.org/wiki/Documentation/Nightly/Developers/FAQ#What_is_the_difference_between_Slicer_Plot_and_Chart_.3F)).

I never used QWT. In theory it looks like it could be added to Slicer’s Qt build but I’m not sure how much work that would vs making the same features in VTK.

Slicer’s [transform display functions](https://slicer.readthedocs.io/en/latest/user_guide/modules/transforms.html#display) are a good example of what you can do in Slicer/VTK.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/4/6433f542dbbb78dfe8ba2702120a5bcfbd74823e.jpeg)

---

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [July 14, 2021, 3:17pm UTC](https://discourse.slicer.org/t/2d-visualization-in-slicer-spectrogram-contour-plot/18727/3 "2021-07-14T15:17:18Z")

</div>

Thank you, then I will try VTK for 2D plotting

By the way does Slicer use Matplotlib? Just wondering

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 14, 2021, 6:34pm UTC](https://discourse.slicer.org/t/2d-visualization-in-slicer-spectrogram-contour-plot/18727/4 "2021-07-14T18:34:14Z")

</div>

> [@keri](#):
>
> By the way does Slicer use Matplotlib? Just wondering

It’s a bit clunky but you can do it with something like this:  
[https://www.slicer.org/wiki/Slicer3:Python#Matplotlib\_plotting\_functionality](https://www.slicer.org/wiki/Slicer3:Python#Matplotlib_plotting_functionality)

Or you can use SlicerJupyter.

---

<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:** [July 14, 2021, 11:41pm UTC](https://discourse.slicer.org/t/2d-visualization-in-slicer-spectrogram-contour-plot/18727/5 "2021-07-14T23:41:02Z")

</div>

You can create static plots using any of the Python plotting packages (there are literally hundreds of them). Integrating interactions is a bit more tricky.

[Visual appearance of QWT plots](https://qwt.sourceforge.io/#screenshotsonmainpage) are about just as rudimentary as VTK (looks like designed by engineers and not artists). So, I’m not sure it would be a significant step up from VTK, and it would require some work to connect it with VTK data structures (that Slicer uses not just for visualization but as data model) and with the Slicer GUI.

We use VTK plots for real-time spectrogram plots of diffuse reflective spectroscopy, see for example here:

[![](https://img.youtube.com/vi/ag7fWY27lus/maxresdefault.jpg "Navigated optical spectroscopy") ](https://www.youtube.com/watch?v=ag7fWY27lus)

It may be better to use VTK plots for interactive visualization and some Python packages for large, complex, static plots.
