Zooming in an extra axis?

2 views (last 30 days)
lightworks
lightworks on 12 Mar 2013
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!

Answers (1)

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

Sign in to comment.

Categories

Find more on Axes Appearance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!