How do I add a colorbar to a polarscatter chart?

11 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Dave B
Dave B il 14 Gen 2023
Modificato: Dave B il 14 Gen 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

Più risposte (0)

Categorie

Scopri di più su Colormaps in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by