Plot with hidden information!!

6 ビュー (過去 30 日間)
Hamid
Hamid 2018 年 2 月 8 日
コメント済み: Hamid 2018 年 2 月 12 日
I have a question about plotting my data in MATLAB. I am trying to plot a 2-D figure, and I can do that!! I want to add information in each point in my figure, and I know that I can do that by TEXT!! But my problem is that I want this information in all the point be hidden and when I am clicking on each point, the information related to that point be shown.Like when you use Root-locus, and click in any point it shows some information related to the clicked point.
would you please let me know if you can help me with this issue?
Yours Sincerely

回答 (2 件)

Jan
Jan 2018 年 2 月 8 日
編集済み: Jan 2018 年 2 月 8 日
This creates a point and an invisible text. If you click on the point, the ButtonDownFcn is triggered and the visibility is toggled:
function main
axes;
Text1H = text(0.5, 0.5, 'Center', 'Visible', 'off');
plot(0.5, 0.5, 'ro', 'ButtonDownFcn', {@toggleText, Text1H});
Text2H = text(0.25, 0.25, 'Down Left', 'Visible', 'off');
plot(0.25, 0.25, 'bo', 'ButtonDownFcn', {@toggleText, Text2H});
end
function toggleText(LineH, EventData, TextH)
vis = get(TextH, 'Visible');
if strcmp(vis, 'on')
set(TextH, 'Visible', 'off');
else
set(TextH, 'Visible', 'on');
end
end
  1 件のコメント
Hamid
Hamid 2018 年 2 月 12 日
Hi, thanks for answering But, when I run it, and I click one the point , it gives me this message:
Error using matlab.graphics.primitive.Text/get Invalid or deleted object.
Error in toggleText (line 2) vis = get(TextH, 'Visible');
Error while evaluating Line ButtonDownFcn.
Would you please let me know how I can solve it?

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


Steven Lord
Steven Lord 2018 年 2 月 8 日
It sounds like you want a data cursor. You can customize the function that generates the text to be displayed in the data cursor to include exactly the information you want to show in a specific format. Search for "Customizing Data Cursor Text" on the page to which I linked for more information.

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by