Zooming in an extra axis?

2 次查看(过去 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 中查找有关 Axes Appearance 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by