# How to use a colormap to paint a matrix in matplot with \[0, 1\] ranges?

**URL:** <https://scilab.discourse.group/t/how-to-use-a-colormap-to-paint-a-matrix-in-matplot-with-0-1-ranges/392>\
**Category:** Scilab beginners\
**Created:** [February 11, 2024, 11:25pm UTC](https://scilab.discourse.group/t/how-to-use-a-colormap-to-paint-a-matrix-in-matplot-with-0-1-ranges/392 "2024-02-11T23:25:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcbritobr](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/jcbritobr/32/363_2.png) [@jcbritobr](https://scilab.discourse.group/u/jcbritobr)\
**Post date:** [February 11, 2024, 11:25pm UTC](https://scilab.discourse.group/t/how-to-use-a-colormap-to-paint-a-matrix-in-matplot-with-0-1-ranges/392/1 "2024-02-11T23:25:27Z")

</div>

Hello, good evening.  
I would like to know how I cant paint a random matrix in matplot with values ranging from 0.1. Matplot always will paint it with black because the lower values (0.3, 0.45…)

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [February 12, 2024, 7:50am UTC](https://scilab.discourse.group/t/how-to-use-a-colormap-to-paint-a-matrix-in-matplot-with-0-1-ranges/392/2 "2024-02-12T07:50:17Z")

</div>

Hello,

Matplot input values are indices in the current colormap, hence to represent values between 0 and 1 you have to multiply actual values by the current number of colors available in the colormap, e.g.

```auto
a = rand(50,50);
N = 128;
gcf().color_map = jetcolormap(N);
Matplot(ceil(a*N))

```

 ![Screenshot 2024-02-12 at 08.49.42](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/e0b373c816982a3561c2bda1b01a31832829284d.png)

---

<div class="post-metadata">

**Author:** ![jcbritobr](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/jcbritobr/32/363_2.png) [@jcbritobr](https://scilab.discourse.group/u/jcbritobr)\
**Post date:** [February 12, 2024, 9:43pm UTC](https://scilab.discourse.group/t/how-to-use-a-colormap-to-paint-a-matrix-in-matplot-with-0-1-ranges/392/3 "2024-02-12T21:43:32Z")

</div>

Hello. Thank you. Very nice solution.
