Filter löschen
Filter löschen

How to make the color gradient gradual. In the plot

100 Ansichten (letzte 30 Tage)
Avijit Paul
Avijit Paul am 16 Dez. 2023
Kommentiert: DGM am 16 Dez. 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 Kommentare
Sam Chak
Sam Chak am 16 Dez. 2023
Is this red-to-blue color transition scheme good enough to represent contour levels in the Indian subcontinent?
Avijit Paul
Avijit Paul am 16 Dez. 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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

DGM
DGM am 16 Dez. 2023
Bearbeitet: DGM am 16 Dez. 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 Kommentare
Avijit Paul
Avijit Paul am 16 Dez. 2023
Thanks a lot. Thats whats Iam looking into.
DGM
DGM am 16 Dez. 2023
You might also try looking on the File Exchange. There are many other similar diverging colormap generators.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 16 Dez. 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 Kommentare
Image Analyst
Image Analyst am 16 Dez. 2023
What does "ve" mean?
Avijit Paul
Avijit Paul am 16 Dez. 2023
Negative and Positive Values

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