How do I add a colorbar to a polarscatter chart?

23 次查看(过去 30 天)
How can I add a colorbar based on the ''value'' value for my Polarscatter chart?
azi_dif=36;
deggorad=pi/180;
azi=[0;36;72;108;144;180;216;252;-288;324;360];
th =deggorad*azi;
radi=[0;0.1;0.3;0.5;0.8;0.85;1;0.9;0.65;0.84;0.86];
val=[15;20;14;17;19;15;13;14;17;19;22];
cn = ceil(max(val));
cm = colormap(jet(cn));
figure(2)
s=polarscatter(th, radi, [], cm(fix(val),:), 'filled');
colorbar
s.SizeData =100;
grid on

采纳的回答

Dave B
Dave B 2023-1-14
编辑:Dave B 2023-1-14
I think you can simplify this task by passing the data directly into scatter
deggorad=pi/180;
azi=[0;36;72;108;144;180;216;252;-288;324;360];
th = deggorad*azi;
radi=[0;0.1;0.3;0.5;0.8;0.85;1;0.9;0.65;0.84;0.86];
val=[15;20;14;17;19;15;13;14;17;19;22];
% just pass in val to polarscatter, then use colormap and CLim to control the colors and limits
% note that passing in a value to jet makes the more 'discrete' looking map
figure(2)
s=polarscatter(th, radi, 100, val, 'filled');
% You can use the caxis in place of the set below in old versions
% and clim in more recent releases
set(gca,"CLim",[1 22])
colormap(jet(max(val)))
colorbar

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by