필터 지우기
필터 지우기

Displaying extra information for datapoints on a plot

조회 수: 4 (최근 30일)
htrh5
htrh5 2015년 5월 26일
답변: Walter Roberson 2015년 5월 26일
Lets say I have two vectors x and y, which describe the position. When I plot them, I want to click on a data point and be able to see the t (time) value which I have created those vectors with. Is this possible, how would I do it?

답변 (1개)

Walter Roberson
Walter Roberson 2015년 5월 26일
See datacursormode() and set an UpdateFcn on it. Return a cell array of strings representing the text to be displayed.
The event structure passed in will tell you your X and Y coordinates, but will not directly tell you which point you are examining. You can calculate Euclidean distances from your known points in order to figure out which graph point you are closest to, which gives you the index, you access your time array at the index, create suitable text, and Viola's Your Uncle.
Or you could instead cheat a little by drawing in 3D with the Z being your time coordinate, and telling view() that you want to look down from the top so that only the X and Y affect the drawing. Then you either say that it is Good Enough that the data cursor displays the time under the name 'Z', or else you write a simple UpdateFcn that grabs the X, Y, Z, and outputs text naming them as X, Y, and T.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by