change color scheme of a scatter plot
Show older comments

here above you can see i have a 2-D Scatter plot. now i want to change the color scheme.
for all the values
- values <= 10 ----- green color
- (10<values<=20) ----- yellow color (for intermediate values i.e for 13 or 16 let yellow shades become darker and similar for all 4 ranges)
- (20 < values <= 50) ----- orange color
- (50 < values ) ---- red color.
Accepted Answer
More Answers (2)
KSSV
on 27 May 2020
You should follow like this demo:
n = 100 ;
x = 1:n ;
y = rand(size(x)) ;
% divide based on values
idx1 = y >=0 & y<0.25 ;
idx2 = y >=0.25 & y<0.5 ;
idx3 = y >=0.5 & y<0.75 ;
idx4 = y >=0.75 & y < 1 ;
figure
hold on
plot(x(idx1),y(idx1),'*r')
plot(x(idx2),y(idx2),'*b')
plot(x(idx3),y(idx3),'*g')
plot(x(idx4),y(idx4),'*k')
5 Comments
Sajid Afaque
on 28 May 2020
KSSV
on 28 May 2020
Okay..you can use scatter instead of plot....
Sajid Afaque
on 28 May 2020
darova
on 28 May 2020
What kind of explanation do you need?
Sajid Afaque
on 29 May 2020
Pamudu Ranasinghe
on 16 Jun 2022
Edited: KSSV
on 16 Jun 2022
1 vote
use gscatter it is easy
Categories
Find more on Scatter Plots 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!