필터 지우기
필터 지우기

How to make the color gradient gradual. In the plot

조회 수: 100 (최근 30일)
Avijit Paul
Avijit Paul 2023년 12월 16일
댓글: DGM 2023년 12월 16일
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
Sam Chak
Sam Chak 2023년 12월 16일
Is this red-to-blue color transition scheme good enough to represent contour levels in the Indian subcontinent?
Avijit Paul
Avijit Paul 2023년 12월 16일
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

댓글을 달려면 로그인하십시오.

채택된 답변

DGM
DGM 2023년 12월 16일
편집: DGM 2023년 12월 16일
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
Avijit Paul
Avijit Paul 2023년 12월 16일
Thanks a lot. Thats whats Iam looking into.
DGM
DGM 2023년 12월 16일
You might also try looking on the File Exchange. There are many other similar diverging colormap generators.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2023년 12월 16일
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
Image Analyst
Image Analyst 2023년 12월 16일
What does "ve" mean?
Avijit Paul
Avijit Paul 2023년 12월 16일
Negative and Positive Values

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by