Here is an example of a figure that you can find in the matlab help with the colorbar function.
My interrogation is very simple. I would like to set a specific color at a specific value on the colorbar. For instance, I would like to have cyan at 4 rather than 0. I don't just want to replace the color there, the goal is to adapt the rest of my colorbar to that value. In my example, I would like the blue shades to be between -6 and 4 and the rest of the colors to be between 4 and 8.
Anyone can help me please ?

Weitere Antworten (1)

Jiri Hajek
Jiri Hajek am 14 Dez. 2022

0 Stimmen

Seems like you need to focus on colormap, that's the function which defines your color scale. Or maybe just change the scale for your plot, that way you may be able to shift the color levels, if that's sufficient for you.

5 Kommentare

Gaétan Andriano
Gaétan Andriano am 14 Dez. 2022
Ok I understand the solution you propose but my goal is rather to automate this method depending on a condition (here a specific value of the colorbar). In the spirit of this, here is what I would like to do:
In this example, I would like to specify that the yellow is at the value 0
Jiri Hajek
Jiri Hajek am 14 Dez. 2022
Well, you have several options available, which will give you the desired value at zero, but what about the rest of the olorscale? Do you indeed want to have a different scale for multiple plots, which will share only the color at zero?
Gaétan Andriano
Gaétan Andriano am 14 Dez. 2022
Yes, that's I would like to do. I want to keep the same colorscale and just set yellow at 0
Jiri Hajek
Jiri Hajek am 14 Dez. 2022
And what about keeping the whole colorscale fixed at such values, so that zero would be at yellow? In my eyes, that would be the best thing for comparability and generality of the solution - and simplicity, to be sure.
Gaétan Andriano
Gaétan Andriano am 16 Dez. 2022
Thanks for your help and I hope this link could help other users of Matlab

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by