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

12 visualizaciones (últimos 30 días)
Hengkai Wu
Hengkai Wu el 18 de Abr. de 2020
Comentada: Tommy el 23 de Ag. de 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.

Respuesta aceptada

Tommy
Tommy el 18 de Abr. de 2020
Editada: Tommy el 18 de Abr. de 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 comentarios
Tommy
Tommy el 19 de Abr. de 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')
Hengkai Wu
Hengkai Wu el 20 de Abr. de 2020
Thanks for your help. XD

Iniciar sesión para comentar.

Más respuestas (1)

zein
zein el 22 de Ag. de 2020
Editada: zein el 22 de Ag. de 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 comentario
Tommy
Tommy el 23 de Ag. de 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

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by