|
This works great. Thanks!
Another small question. What I want to do, now the the
datatips are plotted, is let the user change their
locations manually, if needed. However, when I set the
datacursormode to on, and try to move one of the datatips,
it doesn't move to the next point on the plot, but falls
to the first one. Any ideas?
Thanks,
Daphne
"helper " <spamless@nospam.com> wrote in message <g02in1
$mhk$1@fred.mathworks.com>...
> "Daphne " <daphnew_too_nospam@yahoo.com> wrote in
message
> <g02208$r3i$1@fred.mathworks.com>...
> >
> > If you do find a way to mark the datatips I would
> > appreciate it.
>
>
> Ok. I found a method. Note that this is undocumented
and
> is guaranteed to change in future releases, and I'm not
> sure what I am really doing, but it does work for now.
>
> If you create a plot using:
>
> hPlot = plot(X,Y);
>
> And you want to create a datatip at index "I" of the
data,
> use the following command to get a handle to the
datacursor:
>
> hDC = datacursormode;
> set(hDC,'Enable','off')
>
> Then, use the following commands to create your datatip:
>
> h = createDatatip(hDC, hPlot);
> drawnow
> set(h,'Position',[X(I) Y(I)],...
> 'String',sprintf('X: %s\nY: %s',...
> num2str(X(I)),num2str(Y(I))));
>
>
> However, if you want to create more than one datatip at
a
> time, note that the next call to createDatatip messes
> things up for some reason. Therefore, issue all
> createDatatip commands at first, then set the
properties.
> For example:
>
> I = [3 8];
> for n = 1:length(I)
> h(n) = createDatatip(hDC, hPlot);
> end
> drawnow
> for n = 1:length(I)
> set(h(n),'Position',[X(I(n)) Y(I(n))],...
> 'String',sprintf('X: %s\nY: %s',...
> num2str(X(I(n))),num2str(Y(I(n)))));
> end
>
> I found many variations and different methods, but this
one
> seems to work.
|