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)
Customize color map for temperature and precipitation
66 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
更多回答(1 个)
Cris LaPierre
2020-3-21
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 个评论
Cris LaPierre
2020-3-21
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
2020-3-21
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!