How can I plot multiples lines with differents radius scales in the same figure?

1 Ansicht (letzte 30 Tage)
I have two variables, a and b to plot with my angle vector on the same figure with polar plot. But a and b have very different radii, so every time I plot them together using hold on one it becomes invisible. Does anyone have an idea how to plot a and b on the same figure with different radius scales?
  1 Kommentar
dpb
dpb am 5 Aug. 2019
Well, my first idea was to use
figure
pax = polaraxes;
theta = 0:0.01:2*pi;
rho = sin(2*theta).*cos(2*theta);
polarplot(theta,rho)
pax.ThetaDir = 'clockwise';
pax.FontSize = 12;
hAxR=pax.RAxis;
hAxR.Scale='log';
but that's unsupported so can't use it to separate out data of sizable scale difference -- even though it might not be suitable even if could, granted.
So, carrying on bravely...
hold on
pax(2) = polaraxes('color','none');
pax(2).ThetaDir='counterclockwise';
pax(2).ThetaAxis.Visible='off';
pax(2).RAxisLocation=260;
makes it appear that with enough diligence one could "roll your own" equivalent of plotyy or the newfangled yyaxis for a polar plot, too, and have two r axes scaled differently on the same basic axes location.
Need to create the second with all the same attributes of the first besides just position as the above didn't in its entirety as the example had some non-default settings I didn't clear before making the experiment.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 5 Aug. 2019
The polar and polarplot functions do not allow logarithmic radial axis scaling (taking the log of the radius will be impossible with radius values regardless). Probably the best option is simply to scale the smaller one by multiplying it:
a = linspace(0, 2*pi);
y1 = abs(tan(a));
y2 = 100*abs(cos(a));
figure
polarplot(a, y1)
hold on
polarplot(a, y2)
hold off
legend('$|tan(\theta)|$', '$100\times|cos(\theta)|$', 'Interpreter','latex')
then note the multiplication in the legend.
  1 Kommentar
dpb
dpb am 6 Aug. 2019
I messed around a little more with the two axes...I think it could possibly work well...if OP would attach some typical data to see what is trying to plot...
I'll try to clean up the "just poking" a little and add it...

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