Filter löschen
Filter löschen

Customize color map for temperature and precipitation

70 Ansichten (letzte 30 Tage)
Gulraiz Safdar
Gulraiz Safdar am 20 Mär. 2020
Kommentiert: Cris LaPierre am 21 Mär. 2020
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?

Akzeptierte Antwort

Gulraiz Safdar
Gulraiz Safdar am 21 Mär. 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)
  1 Kommentar
Cris LaPierre
Cris LaPierre am 21 Mär. 2020
If your question has not yet been answered, don't mark it as answered

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Cris LaPierre
Cris LaPierre am 21 Mär. 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 Kommentare
Cris LaPierre
Cris LaPierre am 21 Mär. 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 am 21 Mär. 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Colormaps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by