How to make the color gradient gradual. In the plot
Show older comments
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 Comments
Sam Chak
on 16 Dec 2023
Is this red-to-blue color transition scheme good enough to represent contour levels in the Indian subcontinent?

Avijit Paul
on 16 Dec 2023
Accepted Answer
More Answers (1)
Image Analyst
on 16 Dec 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 Comments
Avijit Paul
on 16 Dec 2023
Edited: Avijit Paul
on 16 Dec 2023
Image Analyst
on 16 Dec 2023
Edited: Image Analyst
on 16 Dec 2023
Can't you do that? If you want more colors, then why choose just 4 categories? Why not use all the original data?
How did you plot it with the colormap you're currently using?
lat: [8.25 8.25 8.25 8.25 8.5 8.5 8.5 8.5 8.5 8.5 8.75 8.75 8.75 8.75 8.75 8.75 8.75 9 9 9 … ] (1×4964 double)
lon: [77 77.25 77.5 77.75 76.75 77 77.25 77.5 77.75 78 76.5 76.75 77 77.25 77.5 77.75 78 … ] (1×4964 double)
rain: [-39.6030071614142 -34.1835228448315 -35.321538273426 -44.9556236112198 … ] (1×4964 double)
How can you have negative rain?
Avijit Paul
on 16 Dec 2023
Image Analyst
on 16 Dec 2023
What does "ve" mean?
Avijit Paul
on 16 Dec 2023
Categories
Find more on Red in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
