Customize color map for temperature and precipitation

67 views (last 30 days)
Hi I tried to plot a map using (pcolorm) and by default it get those colors :
My teacher want me to create only a small number of color bins . For temperature from red to blue and for precipitation from brown to green. Like the figure below:
Can someone help me create those colors bins?

Accepted Answer

Gulraiz Safdar
Gulraiz Safdar on 21 Mar 2020
I tried the first script you told me but I want to reverse the colors. Bleu for negative anamoly values and red for positive. How can I do that? Also for precipitation I want colors from brown (negative) to green (positive)

More Answers (1)

Cris LaPierre
Cris LaPierre on 21 Mar 2020
Do you have to exactly reproduce the results or just something similar?
If you notice, the colorbars in the desired output do not smoothly transition from color to color. This is achieved by defining a custom colormap. One way to do this is to extract the desired number of levels from a predefined colormap.
colorMap = hsv(14);
colormap(colorMap);
If there are specific colors you want and the above technique doesn't work, then you can manually define the colors (rgb)
colorMap = [0 0 0; 0 0 1; 0 1 0; 0 1 1; 1 0 0; 1 0 1; 1 1 0; 1 1 1];
colormap(colorMap);
Applying a colormap will still try to fit the full range of values. If you want to restrict them to a specific range, use the caxis function.
caxis([-5,5])
  2 Comments
Cris LaPierre
Cris LaPierre on 21 Mar 2020
EDIT: Moving reply from Gulraiz Safdar here
I tried the first script you told me but I want to reverse the colors. Bleu for negative anamoly values and red for positive. How can I do that? Also for precipitation I want colors from brown (negative) to green (positive)
Cris LaPierre
Cris LaPierre on 21 Mar 2020
Select a colormap that has blue on the left and red on the right.
It looks like jet might work. Update the code to use jet instead of hsv.

Sign in to comment.

Categories

Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!