Borrar filtros
Borrar filtros

How to make the color gradient gradual. In the plot

100 visualizaciones (últimos 30 días)
Avijit Paul
Avijit Paul el 16 de Dic. de 2023
Comentada: DGM el 16 de Dic. de 2023
How to make the colour gradient gradual. Note I want to use two colours -ve values in blue gradaul varies with values similarly for the +ve values with red .Data set is attached. I have tried it by grouping, it is working but not statisfied.
  2 comentarios
Sam Chak
Sam Chak el 16 de Dic. de 2023
Is this red-to-blue color transition scheme good enough to represent contour levels in the Indian subcontinent?
Avijit Paul
Avijit Paul el 16 de Dic. de 2023
My primary and only aim is to get 2 smooth gradient of two contrast colours to distinguish between negative and positive values. Have to plot it to see how it looks. What is the colormap scheme ? Thanks

Iniciar sesión para comentar.

Respuesta aceptada

DGM
DGM el 16 de Dic. de 2023
Editada: DGM el 16 de Dic. de 2023
I'm going to ignore the fact that using a smooth colorbar with discrete-valued data makes the plot unreadable. If you just want a colormap generator that sweeps between the four given colors, then here it is.
load India_data.mat
CT = bluered(10); % any even integer
scatter(lon,lat,20,rain,"filled");
xticks([66 74 82 90 98]);
xticklabels([66 74 82 90 98]);
ylim([6.5 39.5]);
yticks([8 14 20 26 32 38]);
colormap(CT); % C contains the 4 colors of choice
d = colorbar;
clim([-50 50])
%d.Ticks = linspace(1, 4, 9);
%d.TickLabels=["-40","","-20","","0","","20","","40"];
ylabel("Latitude","FontSize",16);
xlabel("Longitude","FontSize",16);
%ylabel(a,'RMSE','FontSize',16);
title('SSP126 2041-2070','FontSize',18);
The lack of contrast between the given colors isn't helping with readability, but that's what's given. You could use different colors.
CT = bluered_hicont(10); % any even integer
scatter(lon,lat,20,rain,"filled");
xticks([66 74 82 90 98]);
xticklabels([66 74 82 90 98]);
ylim([6.5 39.5]);
yticks([8 14 20 26 32 38]);
colormap(CT); % C contains the 4 colors of choice
d = colorbar;
clim([-50 50])
%d.Ticks = linspace(1, 4, 9);
%d.TickLabels=["-40","","-20","","0","","20","","40"];
ylabel("Latitude","FontSize",16);
xlabel("Longitude","FontSize",16);
%ylabel(a,'RMSE','FontSize',16);
title('SSP126 2041-2070','FontSize',18);
  2 comentarios
Avijit Paul
Avijit Paul el 16 de Dic. de 2023
Thanks a lot. Thats whats Iam looking into.
DGM
DGM el 16 de Dic. de 2023
You might also try looking on the File Exchange. There are many other similar diverging colormap generators.

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 16 de Dic. de 2023
The number of colors depends on the number of unique values in your data as well as the number of unique colors in your colormap.
Does this require the Mapping Toolbox? How did you plot this data?
It looks like your data has (perhaps) only 4 unique values. If so, you can get more by assigning the data to a digital image (matrix) and then use conv2 or imfilter to blur the image. Then create a colormap with more steps in it.
% Blur image
windowWidth = 5;
kernel = ones(windowWidth) / windowWidth^2;
blurredImage = conv2(yourImage, kernel, 'same');
% Create color map
numColors = 256;
redRamp = 1 : numColors;
blueRamp = numColors : -1 : 1;
greenRamp = zeros(numColors, 1);
cmap = [redRamp(:), greenRamp, blueRamp(:)];
% Display blurred image with colormap.
imshow(blurredImage, []);
colormap(cmap);
colorbar;
  5 comentarios
Image Analyst
Image Analyst el 16 de Dic. de 2023
What does "ve" mean?
Avijit Paul
Avijit Paul el 16 de Dic. de 2023
Negative and Positive Values

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