Can anyone help me on why the contour plaot is messed?
1 次查看(过去 30 天)
显示 更早的评论
Hello All, Attached it the contour plot of my code:
I have it in the GUI.
0 个评论
采纳的回答
Walter Roberson
2016-7-15
You appear to be using R2014a or earlier. In those releases, uicontrol always appeared on top of any other content, so when you positioned your plot axes on top of your uicontrol('style','push'), the uicontrol showed up on top instead of your plot covering up your pushbutton (which would have made it difficult to click the push button.)
Your basic problem is that you have not taken enough care to be sure that your pushbutton and your plot axes do not overlap.
You appear to have given a very small area for your plot axes.
My speculation is that you are probably using contour() expecting that the current axes is the correct axes to draw in, but that your current axes has become something different than what you expect. There are a number of reasons that a current axes might not be what you expect, including that you might be in debugging mode and when you clicked on a graph to move it out of the way so you could see the command window (or variable browser or the like), that click would change the current axes.
It is safer to assume that the current axes could change at any time, and so always pass the axes to all plotting routines. For example,
ax = handles.axes17; %an axes you defined in GUIDE
contour(ax, X, Y, Z, levels)
hold(ax, 'on')
title(ax, 'Cool little contour plot')
plot(ax, 1:10, rand(1,10), 'r')
colorbar(ax)
set(ax, 'xgrid', 'on')
Notice how this code never uses gca itself and never assumes that the "current axes" is the one to draw into.
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!