How to prevent contour plot from setting axis limits?
25 views (last 30 days)
I'm trying to add a contour plot over a regular plot on the same axes. It almost works, but every time I add the contour plot to the figure, it overrides the axis size. This is done within the app editor, but I had the same problem in regular Matlab. As far as I can tell, the problem is that there is something inherent to the Contour command that crops the axes to the available data, which in my case makes it harder to see what's on the plot.
Is there some way to force a contour plot to exist on a larger canvas than its data fills?
Dave B on 13 Jan 2022
Edited: Dave B on 13 Jan 2022
contour doesn't reset the limits, perhaps you didn't set hold to on? or didn't specify x and y for your contour? If you're still having trouble, it might be helpful to include some code...
plot([-10 10],[-10 10])
If, on the other hand, you want the contour to be bigger than the axes, set your limits (or just the LimitMode property) before adding the contour:
plot([-1 1],[-1 1])
% alternatively: xlim manual;ylim manual
% alternatively: set(gca,'XLim',get(gca,'XLim')); set(gca,'YLim',get(gca,'YLim'));