필터 지우기
필터 지우기

How can I set an axis outside the polar figure like this photo?

조회 수: 13 (최근 30일)
Hengkai Wu
Hengkai Wu 2020년 4월 18일
댓글: Tommy 2020년 8월 23일
Hello friends,
I want to add a scalebar of my r-axis and label it like the figure I show (with red ring), but it seem not easy to move the exsisting axis, what should I do?
Can anyone help me? I really appreciate it.

채택된 답변

Tommy
Tommy 2020년 4월 18일
편집: Tommy 2020년 4월 18일
You could create Cartesian axes which overlie the polar axes and are invisible except for the y axis, whose ticks are set to match the r axis ticks:
pa = polaraxes('Position', [0.25 0.25 0.6 0.6]);
polarplot(pa, randi(10,10,1),'o');
pa.RTickLabel = [];
a = axes('Color', 'none',...
'XColor', 'none',...
'Position', pa.Position,...
'YLim', [-pa.RLim(2) pa.RLim(2)],...
'YTick', unique([-flip(pa.RTick) pa.RTick]));
ylabel(a, 'r axis label')
  댓글 수: 3
Tommy
Tommy 2020년 4월 19일
Oh of course! Not sure how I overlooked that... You could specify the tick labels:
pa = polaraxes('Position', [0.25 0.25 0.6 0.6]);
polarplot(pa, randi(10,10,1),'o');
pa.RTickLabel = [];
ticks = [-flip(pa.RTick(2:end)) pa.RTick];
a = axes('Color', 'none',...
'XColor', 'none',...
'Position', pa.Position,...
'YLim', [-pa.RLim(2) pa.RLim(2)],...
'YTick', ticks,...
'YTickLabel', abs(ticks));
ylabel(a, 'r axis label')
Hengkai Wu
Hengkai Wu 2020년 4월 20일
Thanks for your help. XD

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

zein
zein 2020년 8월 22일
편집: zein 2020년 8월 22일
how can i modify the rlabel to be starting from 70 instread of zero as i have used the same code but for my case i want the scale to start from 70 instead of zero as shown in the following figure
I have used the same code line but the output rlabel started from zero
what should i modify in the code to set the rlabel from (70-120)
figure(2)
set(gcf,'color','w');
ax = polaraxes('Position', [0.25 0.25 0.6 0.6])
polarplot (theta,splbn(21,:));
ax.ThetaDir = 'counterclockwise';
ax.ThetaZeroLocation = 'left';
rlim([70,120])
ax.RTickLabel = [];
ticks = [-flip(ax.RTick(2:end)) ax.RTick];
a = axes('Color', 'none',...
'XColor', 'none',...
'Position', ax.Position,...
'YLim', [-ax.RLim(2) ax.RLim(2)],...
'YTick', ticks,...
'YTickLabel', abs(ticks));
ylabel(a, 'r axis label')
  댓글 수: 1
Tommy
Tommy 2020년 8월 23일
Hello, try this:
figure(2)
set(gcf,'color','w');
ax = polaraxes('Position', [0.25 0.25 0.6 0.6]);
polarplot (theta,splbn(21,:));
ax.ThetaDir = 'counterclockwise';
ax.ThetaZeroLocation = 'left';
ax.RTickLabel = [];
% grab the tick locations before changing the r limits, because the
% tick locations should be centered around 0:
ticklocs = [-flip(ax.RTick(2:end)) ax.RTick];
rlim(ax, [70,120])
ticks = [-flip(ax.RTick(2:end)) ax.RTick];
a = axes('Color', 'none',...
'XColor', 'none',...
'Position', ax.Position,...
'YLim', [min(ticklocs), max(ticklocs)],...
'YTick', ticklocs,... use the tick locations to place the ticks
'YTickLabel', abs(ticks));
ylabel(a, 'r axis label')
Hopefully this works for you

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by