Need to know how to put datatip in-between two indices

3 views (last 30 days)
Hi all!
I'd like to add datatips to a graph of mine at locations that are not necessarily positive integer indices. The indices on the x-axis might for example be 3.14 or 1.414.
A simple example of how to go about inserting these datatips: http://techblog.arinn.net/2013/08/programmatic-manipulation-of-datatips-in-matlab/
How to make e.g. makedatatip(ph,[1.414 3.14) work with the plot handle is an open question. I appreciate your help kindly.
  6 Comments
per isakson
per isakson on 13 Jul 2014
AFAIK: "between two indices" . It is not possible.
dpb
dpb on 13 Jul 2014
Indeed, w/ the code as given it isn't...inside we find the following--
...
X = get(hObj,'XData'); % the X,Y data for the lines of the figure
Y = get(hObj,'YData');
...
% Loop through each specified data point
for n = 1:size(index,1)
% Create position vector
...
elseif isempty(Z)
pos = [X(index(n)) Y(index(n))];
...
% Create datatip
hDatatip(n) = createDatatip(hDataCursorMgr, hObj);
...
set(hDatatip(n),'Position',pos)
So, you can see the position vector is created only from the actual datapoints in the graph by this function.
It does seem somewhat peculiar that only indices are accepted as the arguments; looks like to use it for numeric data you'll have to first do a find on the figure datapoints to return the nearest point(s) to the location you'd like to locate the datatip but as Per says (and the code above verifies) it's going to have to be at that index, not at some arbitrary [x,y] position.
I don't have any idea what the actual abilities are within the object createDatatip creates are; whether it also has a way to set a location based on the x,y coordinates of the axes object as well as at a particular index altho one would assume the latter translates to the former but whether its exposed or not would be the key...

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!