Path: news.mathworks.com!not-for-mail
From: "Daphne " <daphnew_too_nospam@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Datatip (Datacursormode)
Date: Sat, 10 May 2008 08:13:03 +0000 (UTC)
Organization: Technion
Lines: 73
Message-ID: <g03lef$c19$1@fred.mathworks.com>
References: <g00qvj$4gu$1@fred.mathworks.com> <g016ot$gva$1@fred.mathworks.com> <g02208$r3i$1@fred.mathworks.com> <g02in1$mhk$1@fred.mathworks.com>
Reply-To: "Daphne " <daphnew_too_nospam@yahoo.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210407183 12329 172.30.248.37 (10 May 2008 08:13:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 10 May 2008 08:13:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1066798
Xref: news.mathworks.com comp.soft-sys.matlab:467680



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.