Filter löschen
Filter löschen

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

13 Ansichten (letzte 30 Tage)
Hengkai Wu
Hengkai Wu am 18 Apr. 2020
Kommentiert: Tommy am 23 Aug. 2020
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.

Akzeptierte Antwort

Tommy
Tommy am 18 Apr. 2020
Bearbeitet: Tommy am 18 Apr. 2020
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 Kommentare
Tommy
Tommy am 19 Apr. 2020
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')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

zein
zein am 22 Aug. 2020
Bearbeitet: zein am 22 Aug. 2020
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 Kommentar
Tommy
Tommy am 23 Aug. 2020
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Polar Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by