How can I set an axis outside the polar figure like this photo?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
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
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')
Weitere Antworten (1)
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
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
Siehe auch
Kategorien
Mehr zu Graphics Object Programming 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!