Inconsistent xlim when using yyplot (matlab 2014a)
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
dpb
2016 年 12 月 12 日
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...
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Two y-axis についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!