Extracting data from lines in a plot

4 ビュー (過去 30 日間)
Sina Abolhoseini
Sina Abolhoseini 2014 年 5 月 30 日
コメント済み: Hugo 2014 年 6 月 2 日
Hi First I'd like to apologize for my poor english. I'm writing a program, in one part I am plotting different lines which allow the users to select a pair of them (lines) for further actions. To identify the best pairs user must be informed with critical information like (hour, height, magnitude ). I want to show this 3 as data tips. But I don't know how to show each lines properties differently.
As you see in the picture, Lines are labeled. For each number I have a magnitude. I want to show that Mag in the data tip! What you see in the picture is something fake which I made to show what I mean. It's a constant number for mag which must be something different for different lines.

回答 (2 件)

Hugo
Hugo 2014 年 5 月 30 日
Have you tried using the command text()? Suppose that the tip of one of the lines is in (a,b). Then you can just do
text(a,b,yourtexthere,'HorizontalAlignment','center','VerticalAlignment','middle');
That will just write some text at the tip of the line. You can write it wherever you want by changing the values of a and b. The values or a and b are scaled according to the axes.
Or do you want something that appears automatically only when the user is pointing at the line with the mouse.
Best regards,
  2 件のコメント
Sina Abolhoseini
Sina Abolhoseini 2014 年 5 月 30 日
Hi, Thank you for your concern. But I think you didn't got my problem. I need somehow identifying different lines. For example clicking on line 369 and it shows me 5 , then I click on line 283 and it shows 2. How should I relate the lines with values from another place?!!!
Hugo
Hugo 2014 年 6 月 2 日
I think my second answer should solve this problem. What I suggested there was to attach to each line a contextual menu. To show specific data, just replace the labels with what you want to show. If not, I may still not get what you want.

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


Hugo
Hugo 2014 年 5 月 30 日
Just in case, you could also provide a contextual menu by doing the following
hmenu=uicontextmenu;
uimenu(hmenu,'Label','MAG=something');
uimenu(hmenu,'Label','NUM=something');
uimenu(hmenu,'Label','TIME=something');
set(hline,'uicontextmenu',hmenu);
Here hmenu is a handle for the contextual menu, and hline is the handle of the line you created. For seeing the menu, the user must right-click on the line.
Hope this helps.

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by