필터 지우기
필터 지우기

How do I add a colorbar to a polarscatter chart?

조회 수: 23 (최근 30일)
Alexi
Alexi 2023년 1월 14일
댓글: Alexi 2023년 1월 14일
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