Customize color map for temperature and precipitation

59 visualizaciones (últimos 30 días)
Gulraiz Safdar
Gulraiz Safdar el 20 de Mzo. de 2020
Comentada: Cris LaPierre el 21 de Mzo. de 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?

Respuesta aceptada

Gulraiz Safdar
Gulraiz Safdar el 21 de Mzo. de 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 comentario
Cris LaPierre
Cris LaPierre el 21 de Mzo. de 2020
If your question has not yet been answered, don't mark it as answered

Iniciar sesión para comentar.

Más respuestas (1)

Cris LaPierre
Cris LaPierre el 21 de Mzo. de 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 comentarios
Cris LaPierre
Cris LaPierre el 21 de Mzo. de 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 el 21 de Mzo. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by