Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Zoom out problem with two x-linked axes containing data in different ranges

조회 수: 1 (최근 30일)
Soren Preus
Soren Preus 2012년 10월 31일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi all
I have a zoom problem when plotting in two x-linked axes and would be very happy for any suggestions to solve the problem.
Here's an example:
x1 = 5:10;
y1 = 5:-1:0;
x2 = 0:10;
y2 = 0:10;
hl1 = line(x1,y1,'Color','r');
ax1 = gca;
set(ax1,'XColor','r','YColor','r')
ax2 = axes('Position',get(ax1,'Position'),...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none',...
'XColor','k','YColor','k');
hl2 = line(x2,y2,'Color','k','Parent',ax2);
linkaxes([ax1 ax2],'x')
The problem in the resulting plot is that xlim goes from 5-10 and not 0-10 as it should. Even when I try to zoom out the zooming only goes as far as xlim([5 10]) thus leaving out some of the (x2,y2)-data in the plot.
When plotting (x1,y1) in ax2 and (x2,y2) in ax1 the problem no longer exists, however, I would like to find a different solution as this solution is not really an easy implementation in my actual application.
Any suggestions are appreciated.
Best, SP

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by