create specific color map and save it
3 次查看(过去 30 天)
显示 更早的评论
how do i create my own color map for 2D-scatter plot.
such that all the values of z
- z <= 10 ------- take green color
- 10 < z <= 25 ----- yellow color
- 25 < z <= 50 ----- orange color
- z > 50 ----- red color
i want to create a color map obeying such condition and save it , so that i can use with whatever z i obtain in future.
as an example i have attached x,y,z
scatter(x,y,[],z,'filled','o')
采纳的回答
Ameer Hamza
2020-5-28
Try this
val_z = (10:51).';
idx = 1*(val_z<=10) + ...
2*((10<val_z) & (val_z<=25)) + ...
3*((25<val_z) & (val_z<=50)) + ...
4*(val_z>50);
colors = [0 1 0; % green
1 1 0; % yellow
1 0.5 0; % orange
1 0 0]; % red
cmap = colors(idx, :);
scatter(x,y,[],z,'filled','o')
colormap(cmap)
set(gca, 'CLim', [10 51]);
12 个评论
Ameer Hamza
2020-5-28
I don't have any idea about this. Maybe something is mentioned in archived documentation, but the reason is not obvious.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!