Can anyone help me on why the contour plaot is messed?

조회 수: 1 (최근 30일)
adi kul
adi kul 2016년 7월 15일
답변: Walter Roberson 2016년 7월 15일
Hello All, Attached it the contour plot of my code:
I have it in the GUI.

채택된 답변

Walter Roberson
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개)

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by