フィルターのクリア

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 Center および File ExchangeColormaps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by