How can I set an axis outside the polar figure like this photo?
12 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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
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')
更多回答(1 个)
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
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 Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!