Text and Line only shown in debug mode

Hi,
I am making a GUI. Inside it, I have placed an axes. I am writing a text label and a line, creating a text and a line objects. When I set a breakpoint in the text() or line() functions, the objects are correctly drawn in the axes, but not when I run the script. I am using Matlab R2011a.
Thanks, Luis

回答 (2 件)

Grzegorz Knor
Grzegorz Knor 2011 年 10 月 3 日

0 投票

Maybe add drawnow command after you draw the line, or try to use refresh function.
Luis Andres
Luis Andres 2011 年 10 月 4 日

0 投票

Hi,
I have tried it, but without success. For instance, when I draw a line in an axes called "myAxes", I write:
ylim=get(handles.myAxes,'ylim');
a=50;
line([a;a],ylim,'linewidth',2,'color',[0,0,0]);
So, I don´t make any reference to handles.myAxes in the line. Should I make it?

4 件のコメント

Walter Roberson
Walter Roberson 2011 年 10 月 4 日
line(handles.myAxes, [a;a],ylim,'linewidth',2,'color',[0,0,0]);
Luis Andres
Luis Andres 2011 年 10 月 5 日
I have also tried it, but without success. In fact, this alternative does not work even in debug mode, because a handles cannot be passed as a parameter to 'line'.
Jan
Jan 2011 年 10 月 5 日
Avoid to use "ylim" as name of a variable, because it is a built-in function. But this is not the cause of the problem.
The low-level function LINE needs the property name for the parent:
line('Parent', handles.myAxes, [a;a],ylim,'linewidth',2,'color',[0,0,0]);
You can obtain the handles of the line or text object and check it in non-debug mode:
H = line(... your calling sequenc...)
disp(get(H, 'Parent') == handles.myAxes)
Then you will find out, that the line is drawn to another AXES object. Therefore the specification of the Parent should solve the error.
Walter Roberson
Walter Roberson 2011 年 10 月 5 日
You will probably need to put the 'Parent' parameter _after_ the positional parameters, as in
line([a;a],ylim, 'Parent', handles.myAxes, 'linewidth',2, 'color',[0,0,0]);

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

2011 年 10 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by