How to display plot and rectangle at the same time?

1 回表示 (過去 30 日間)
越琪 吴
越琪 吴 2020 年 10 月 4 日
コメント済み: Adam Danz 2020 年 10 月 4 日
I want to display some lines and some moving rectangles at the same time in the same frame. I use plot() to draw the lines, and rectangle() to draw the rectangles, but they can't display at the same time. And I have tried 'hold on' , but that didn't work, how can i solve the problem?
Any help would be appreciated!
Thanks

採用された回答

Adam Danz
Adam Danz 2020 年 10 月 4 日
" I have tried 'hold on' , but that didn't work"
My guess is that hold on was applied to the wrong axes. This can happen when the taget axis handle is not visible (ie, in App Designer). Specify the target axis handle using,
% ax is the axis handle
plot(ax, ___);
hold(ax,'on');
rectangle(ax, ___)
If this did not solve the problem please provide more detail in your question.
  3 件のコメント
越琪 吴
越琪 吴 2020 年 10 月 4 日
Now I found that if I write the rectangle before, instead of after, the plot, then they can be displayed at the same time in the same frame, why could that happen? I think it's mysterious.
Anyway, thank you for answering my question!
Adam Danz
Adam Danz 2020 年 10 月 4 日
"Do I need to define 'ax'?"
From my answer,
% ax is the axis handle
"Now I found that if I write the rectangle before, instead of after, the plot, then they can be displayed at the same time"
It looks like your rectangle was covering the other object. Nice job fixing that!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDisplay and Exploration についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by