How do I add a colorbar to a polarscatter chart?
16 views (last 30 days)
Show older comments
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
Accepted Answer
Dave B
on 14 Jan 2023
Edited: Dave B
on 14 Jan 2023
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
More Answers (0)
See Also
Categories
Find more on Colormaps 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!