MATLAB: This code gives me a strange plot I cannot figure why. Many thanks for any help

axesplotyyscaling

figure(2);
start=floor(TrajX(1));
stop=floor(TrajX(length(TrajX)));
P3_FzInv = flip(P3_Fz*-1);
subplot(2,1,1); % top plot, P3Fz v. T4T3
[ax,z1,z2]=plotyy(t(start:stop),z1(start:stop),(start:stop),z2(start:stop));
axis('square');
grid on;
set(z1,'LineWidth',2);
set(z2,'LineWidth',2);
xlabel(ax(1),'seconds');
ylabel(ax(1),'Fz <<--- Power Site --->> P3');
ylabel(ax(2),'T3 <<--- Power Site --->> T4');
hold on;
FigHandle = figure(2);
set(FigHandle, 'Position', [100, 100, 1049, 895])

Best Answer

" I was unable to get this subplot axis problem fixed"
Don't know why it didn't register with me before, but the problem is
axis('square')
That's changing the axes shape only for the one, last, active axes object and there are two owing to plotyy
The solution is
h1=subplot(2,1,1);
hAx=plotyy(....
axis(hAx,'square')
which will fixup both. The obvious problem is that the one is so short compared to the other; I let the missing t sidetrack (albeit it was a problem in the original post that would lead to confusing plot as well).
My previous example expanded results in --
from
>> subplot(2,1,1)
>> hAx1=plotyy(1:10,rand(1,10),1:10,10*rand(1,10));
>> axis square
>> subplot(2,1,2)
>> hAx2=plotyy(1:10,rand(1,10),1:10,10*rand(1,10));
>> axis(hAx2,'square')
Note don't even need the subplot axes handles (altho it can't hurt to be specific); just must modify both plotyy axes to keep them in synchronicity. linkaxes might help here altho not sure that it will set the 'position' property; didn't test that.