# How to plot colormap in 3D SLICER，like use imagesc in matlab

**URL:** <https://discourse.slicer.org/t/how-to-plot-colormap-in-3d-slicer-like-use-imagesc-in-matlab/31551>\
**Category:** Community\
**Tags:** plots\
**Created:** [September 4, 2023, 3:30pm UTC](https://discourse.slicer.org/t/how-to-plot-colormap-in-3d-slicer-like-use-imagesc-in-matlab/31551 "2023-09-04T15:30:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![iwangwangwang](https://avatars.discourse-cdn.com/v4/letter/i/f1d935/32.png) [@iwangwangwang](https://discourse.slicer.org/u/iwangwangwang)\
**Post date:** [September 4, 2023, 3:30pm UTC](https://discourse.slicer.org/t/how-to-plot-colormap-in-3d-slicer-like-use-imagesc-in-matlab/31551/1 "2023-09-04T15:30:06Z")

</div>

How to plot colormap in 3D SLICER，like use imagesc in matlab,  
or How to develop the module to Implement the function？

---

<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:** [September 4, 2023, 5:18pm UTC](https://discourse.slicer.org/t/how-to-plot-colormap-in-3d-slicer-like-use-imagesc-in-matlab/31551/2 "2023-09-04T17:18:04Z")

</div>

Hi @iwangwangwang, it’s great to see your interest in developing with Slicer. I saw from another thread that some websites aren’t easily available for you. Are you able to access [https://slicer.readthedocs.io/en/latest/](https://slicer.readthedocs.io/en/latest/) and [Documentation/Nightly/Training - Slicer Wiki](https://www.slicer.org/wiki/Documentation/Nightly/Training) ? These are great places to start learning but let us know if there’s a way to make the information more available to you.

Regarding colormaps, I’m not familiar with matlab, but you should be able to render either direct color (RGB) or map scalar fields through a lookup table. If you look at the documentation and it’s still not clear you can come back here for more specific information. Usually it helps people provide you with answers if you give some more context. [Volumes — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/user_guide/modules/volumes.html)

---

<div class="post-metadata">

**Author:** ![iwangwangwang](https://avatars.discourse-cdn.com/v4/letter/i/f1d935/32.png) [@iwangwangwang](https://discourse.slicer.org/u/iwangwangwang)\
**Post date:** [September 5, 2023, 2:15am UTC](https://discourse.slicer.org/t/how-to-plot-colormap-in-3d-slicer-like-use-imagesc-in-matlab/31551/4 "2023-09-05T02:15:06Z")

</div>

Thanks, but let me provide a more detailed description, I want to plot 2D matrix data with color (RGB) or map scalar fields through a lookup table in 3D Slicer, just like “imshow” in python or “imagesc” in matlab， I think using 2D slice or 3D view representation is all not appropriate in 3D Slicer, so there is any other method to present 2d data ? or must develop a extension to Implement the function？  
sincerely wating for your answers.

---

<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:** [September 5, 2023, 12:00pm UTC](https://discourse.slicer.org/t/how-to-plot-colormap-in-3d-slicer-like-use-imagesc-in-matlab/31551/5 "2023-09-05T12:00:07Z")

</div>

Maybe you just want to us matplotlib directly: [Script repository — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#using-matplotlib)

---

<div class="post-metadata">

**Author:** ![iwangwangwang](https://avatars.discourse-cdn.com/v4/letter/i/f1d935/32.png) [@iwangwangwang](https://discourse.slicer.org/u/iwangwangwang)\
**Post date:** [September 5, 2023, 2:56pm UTC](https://discourse.slicer.org/t/how-to-plot-colormap-in-3d-slicer-like-use-imagesc-in-matlab/31551/6 "2023-09-05T14:56:28Z")

</div>

Of course, using Matplotlib is very convenient, but it can also make my program bulky, after all, I only need to use Matplotlib to draw color maps

---

<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:** [September 5, 2023, 4:20pm UTC](https://discourse.slicer.org/t/how-to-plot-colormap-in-3d-slicer-like-use-imagesc-in-matlab/31551/7 "2023-09-05T16:20:26Z")

</div>

> [@iwangwangwang](#):
>
> to draw color maps

Do you mean you want to display a color legend (color bar that shows what color correspond to what value) and you are not sure how to do it in Slicer?

---

<div class="post-metadata">

**Author:** ![iwangwangwang](https://avatars.discourse-cdn.com/v4/letter/i/f1d935/32.png) [@iwangwangwang](https://discourse.slicer.org/u/iwangwangwang)\
**Post date:** [September 5, 2023, 6:58pm UTC](https://discourse.slicer.org/t/how-to-plot-colormap-in-3d-slicer-like-use-imagesc-in-matlab/31551/8 "2023-09-05T18:58:02Z")

</div>

I meant to plot a Matrix data as colormap, just like function “imshow” in python, I don’t know if I expressed myself clearly，here is a picture for example

![1693940223938](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/2/c2eccf32c2f12a9f324a87135dc3e622b960318d.png)

---

<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:** [September 5, 2023, 8:53pm UTC](https://discourse.slicer.org/t/how-to-plot-colormap-in-3d-slicer-like-use-imagesc-in-matlab/31551/9 "2023-09-05T20:53:32Z")

</div>

Slice views show “matrix data” (2D array) as an image as in your screenshot. You can select what color map you want to use for display and you can also enable displaying a color legend.

Do you have trouble setting these up using the GUI or Python scripting?

---

<div class="post-metadata">

**Author:** ![iwangwangwang](https://avatars.discourse-cdn.com/v4/letter/i/f1d935/32.png) [@iwangwangwang](https://discourse.slicer.org/u/iwangwangwang)\
**Post date:** [September 6, 2023, 1:53am UTC](https://discourse.slicer.org/t/how-to-plot-colormap-in-3d-slicer-like-use-imagesc-in-matlab/31551/10 "2023-09-06T01:53:44Z")

</div>

yes, I have trouble how to implement the function
