Zooming in an extra axis?

조회 수: 4 (최근 30일)
lightworks
lightworks 2013년 3월 12일
Hi!
I have problems in zooming in my plot once it's done (in the Plot window that pops up as an output). I wanted to add a grid to my plot, but only in the horizontal lines and with a lighter color than the default one. I found somewhere in the Internet that the solution was to make an auxiliary axis, and the code for it. So far so good, but when zooming in my plot, i only get a zoom in the auxiliary axes and not in the ploted curves.
Here's what my figure looks like
and here's how it looks after zooming on it:
So, as you can see, the curves didn't get any zoom.
Here's my code (X is my matrix with the data):
cc=jet(6);
figure;
hold on;
month=[1:12];
for i=1:5
plot(month',X(:,i),'color',cc(i,:),...
'LineWidth',2);
pbaspect([1.7 1 1]);
xlim([1 12])
set(gca,'XTick',1:1:12)
set(gca,'XTickLabel', 'E','F','M','A','M','J','J','A','S','O','N','D'})
ylabel('Tmax (ºC)')
xl=xlabel(stid(k));
set(xl,'FontSize',12);
set(t,'Fontsize',12);
legend('Media','Mediana','Análogo1','Pesado','Azar',3);
end
hold on;
B=gca;
C = axes('Position',get(B,'Position'), ...
'Color','none', 'TickLength',[1e-100 1e-100], ...
'XGrid','off', 'YGrid','on', ...
'Box','off','YColor',[0.5 0.5 0.5], ...
'XTickLabel',[], 'YTickLabel',[], ...
'XTick',get(B,'XTick'), 'YTick',get(B,'YTick'), ...
'XLim',[1 12], 'YLim',get(hAx1,'YLim'));
pbaspect([1.7 1 1]);
Any ideas on why is this happening?
Thanks in advance!

답변 (1개)

Walter Roberson
Walter Roberson 2013년 3월 12일
You should not need a second axis. You should just need to set XGrid off and YGrid on.
  댓글 수: 3
Walter Roberson
Walter Roberson 2013년 3월 12일
Configure the new axes to have HitTest off.
lightworks
lightworks 2013년 3월 13일
편집: lightworks 2013년 3월 13일
It's not working. I added
set(C,'HitTest','off');
at the end of the code.
Is that what you ment?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by