Inconsistent xlim when using yyplot (matlab 2014a)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I am trying to plot two y axis onto one x axis using yyplot.
This has worked but i sometimes get inconsistent x limits. I have tried using xlim to correct:
xlim(ax2(1), [1 6]);
xlim(ax2(2), [1 6]);
But this makes both plots disappear! Can anyone tell me what i'm doing wrong? My Code is copied below:
fig = figure('Name','Z4_ATS1_f3 Plot','NumberTitle','off');
ax1 = axes('Position',[0 0 1 1],'Visible','off');
ax2 = axes('Position',[.3 .1 .6 .8]);
xlabel('Distance [meters]');
ylabel('Impedance (absolute)');
descr = {'Impedance Values';
' '
'Towards SATS: ';
'@ 50% distance:'
num2str(Z4_ATS1_f4_toSATS_50);
'With 15% added:';
num2str(Z4_ATS1_f4_toSATS_50_wTol);
' '
'Towards FS: ';
'@ 50% distance:'
num2str(Z4_ATS1_f4_toFS_50);
'With 15% added:';
num2str(Z4_ATS1_f4_toFS_50_wTol)};
axes(ax1) % sets ax1 to current axes
text(.025,0.6,descr);
axes(ax2) % sets to ax2 enables zooming of the graph not the text
[ax2,hlines1,hlines2] = plotyy(dist,abs(Z4_ATS1_f3(L1:L2)),dist,Z4_ATS1_f3ang(L1:L2));
% xlim(ax2(1), [1 6]);
% xlim(ax2(2), [1 6]);
% set(ax2(1),'xtick',0:1:6);
% set(ax2(1),'xlim',[0 6]);
% set(ax2(2),'xtick',0:1:6);
% set(ax2(2),'xlim',[0 6]);
set(ax2(1),'ytick',0:2:20);
set(ax2(1),'ylim',[0 20]);
ylabel(ax2(1),'Impedance (absolute)');
set(ax2(2),'ytick',-180:36:180);
set(ax2(2),'ylim',[-180 180]);
ylabel(ax2(2),'Angle (deg)');
saveas(gcf,['Z4_ATS1_f3.fig']);
5 Kommentare
dpb
am 12 Dez. 2016
What's wrong with just straight plotyy, then as illustrated in the doc if you're still with earlier release or yyaxis in conjunction with standard plot and friends if have HG2 for which plotyy has been deprecated (altho for oldtimers used to working with HG handles directly, it doesn't seem that much benefit to have more "stuff" to do same thing in end, eventually it'll probably come out about the same as far as effort as TMW continues to streamline HG2).
Plot the lines on the two axes as desired, set their y-,xlabels appropriately and add a figure title or use text...
Antworten (0)
Siehe auch
Kategorien
Mehr zu Two y-axis finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!