# How to associate a colormap to fixed z range in Sgrayplot()

**URL:** <https://scilab.discourse.group/t/how-to-associate-a-colormap-to-fixed-z-range-in-sgrayplot/870>\
**Category:** Graphics and plotting\
**Created:** [March 17, 2025, 5:31am UTC](https://scilab.discourse.group/t/how-to-associate-a-colormap-to-fixed-z-range-in-sgrayplot/870 "2025-03-17T05:31:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fmiyara](https://avatars.discourse-cdn.com/v4/letter/f/e68b1a/32.png) [@fmiyara](https://scilab.discourse.group/u/fmiyara)\
**Post date:** [March 17, 2025, 5:31am UTC](https://scilab.discourse.group/t/how-to-associate-a-colormap-to-fixed-z-range-in-sgrayplot/870/1 "2025-03-17T05:31:47Z")

</div>

I would need to be able to use Sgrayplot() in such a way that the color map represents a fixed range of z values, instead of accommodating to the particular extremes of z. As it works by default, the full color map is used regardless of the z range.

For instance, I have two functions, z = f(x,y) and z = g(x,y), the first one ranges from  
0 to 1, the second one, from 0.5 to 0.6. Assuming that I use jet(100) as the color map, I would like to see the full range of colors in the case of f (i.e., indices between 1 and 100), but only the colors between indices 50 and 60 in the case of g. The default behavior is that both plots use the full color range, so the visual comparison is somewhat deceptive as to the real range of each function.

I can imagine several workarounds, but I wonder whether there is a direct or natural way of doing this.

Thanks,

Federico Miyara

---

<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:** [March 17, 2025, 9:01am UTC](https://scilab.discourse.group/t/how-to-associate-a-colormap-to-fixed-z-range-in-sgrayplot/870/2 "2025-03-17T09:01:43Z")

</div>

Hello,

You can use the zminmax and colminmax arguments of Sgrayplot(), they have been tailored for this purpose.

S.

---

<div class="post-metadata">

**Author:** ![fmiyara](https://avatars.discourse-cdn.com/v4/letter/f/e68b1a/32.png) [@fmiyara](https://scilab.discourse.group/u/fmiyara)\
**Post date:** [March 23, 2025, 1:24am UTC](https://scilab.discourse.group/t/how-to-associate-a-colormap-to-fixed-z-range-in-sgrayplot/870/3 "2025-03-23T01:24:13Z")

</div>

Thank you!

The presence of arguments like zminmax=[-0.5 0.5] or colout=[0 0] is somewhat baffling since “=” is the assignment sign, I wouldn’t expect it within an argument list. I would rather expect expressions.

Other functions use pairs such as “zminmax”, [-0.5 0.5] instead

Regards,

Federico Miyara

---

<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:** [March 23, 2025, 7:00pm UTC](https://scilab.discourse.group/t/how-to-associate-a-colormap-to-fixed-z-range-in-sgrayplot/870/4 "2025-03-23T19:00:24Z")

</div>

Named arguments are quite common in Scilab and even Matlab has started to use them. From a developper point of view they are much easier to parse than name/value pairs.

S.

---

<div class="post-metadata">

**Author:** ![fmiyara](https://avatars.discourse-cdn.com/v4/letter/f/e68b1a/32.png) [@fmiyara](https://scilab.discourse.group/u/fmiyara)\
**Post date:** [March 24, 2025, 12:26am UTC](https://scilab.discourse.group/t/how-to-associate-a-colormap-to-fixed-z-range-in-sgrayplot/870/5 "2025-03-24T00:26:09Z")

</div>

Thanks again!

Federico Miyara
