Code covered by the BSD License  

Highlights from
MAKEDATATIP

4.82353
4.8 | 18 ratings Rate this file 57 Downloads (last 30 days) File Size: 2.52 KB File ID: #19877 Version: 1.1
image thumbnail

MAKEDATATIP

by

Tim Farajian (view profile)

 

11 May 2008 (Updated )

Allows programmatically adding datatips to any valid graphical object.

| Watch this File

File Information
Description

MAKEDATATIP allows programmatically adding datatips to some graphical objects.

Updated to allow adding datatips to additional handle objects including scatter plots and images. If there are other object types you want supported that do not currently work, please let me know.

Example:
  x = 1:10;
  y = rand(1,10);
  hPlot = plot(x,y);
  makedatatip(hPlot,[3 8])

Example:
  [X,Y,Z] = peaks(30);
  hObj = surf(X,Y,Z);
  I = [5 8; 20 12; 22 28];
  hDatatip = makedatatip(hObj, I);

Acknowledgements

This file inspired Linkdatatips.

Required Products MATLAB
MATLAB release MATLAB 7.14 (R2012a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (22)
15 Jul 2015 Guanfeng Gao

There shows the Error even when I use the example, could anyone tell me how to fix it?:

Error using get
There is no DataCursor property on the PointDataTip class.

Error in makedatatip (line 139)
set(get(hDatatip(n),'DataCursor'),'DataIndex',index(n, :),...

Comment only
31 May 2015 Kevin J. Delaney

Fantastic! Just what I needed.

09 Mar 2015 Jad

Jad (view profile)

Make the chnages that Illiya recommends and it works just fine.

18 Dec 2014 Mark

Mark (view profile)

 
08 Dec 2014 Iliya

Iliya (view profile)

Useful!
One note though, when using HG2 (the new graphics engine that was officially introduced in MATLAB 2014b), a couple of changes need to be made to the code:
***********CHANGE 1*********
line 122 needs to be:
pos = [X(index(n)) Y(index(n)) 0];
***********CHANGE 2*********
lines 135-141 should be commented OUT

23 Oct 2014 * *

* * (view profile)

 
29 Jul 2013 Alexander Kosenkov  
03 Jun 2013 almog shalom  
12 Nov 2012 Geraint  
12 Nov 2012 Geraint  
09 Oct 2012 Daniel Wirtz

Daniel Wirtz (view profile)

Thanks, quite useful.
Would be nice to also be able to pass an axes/figure handle, which causes the tip to be created for the first graphics object (patch, surface..) found.

10 Jul 2012 Jiro Doke

Jiro Doke (view profile)

This is a very useful, well-written function. His help is complete with many examples. I also like how he has extensive error-checking in the code, to ensure proper usage.

18 Sep 2011 Maider Marin

I have an image and I need to put datatips on pixels in positions [61,98] and [63,94] then I try to use this function calling my image J:
hObj=imshow(J);makedatatip(hObj,[61,98; 63,94])
but I got an error:
??? Error using ==> get
There is no 'ZData' property in the 'image' class.

Then I commented line 65 and write
Z=[]; the truth is I am only going to used for images. But then I have a second error.
??? Attempted to access X(61); index out of bounds because numel(X)=2.

Error in ==> makedatatip at 99
pos = [X(index(n)) Y(index(n))];
Can somebody help me.

Comment only
16 Aug 2011 Benjamin  
21 Jun 2011 Ben

Ben (view profile)

 
05 Aug 2010 Alexandre Schimel

very good, well coded and useful function.
Just a note. I use R2008a and tried to use it on a "imagesc" graphical object. The function doesn't work since image properties have different XData and YData and no Zdata. I had to tweak a little the code.

22 Mar 2010 James Ross

Any chance of posting this using the BSD License?

Comment only
15 Mar 2010 Jason

Jason (view profile)

Is there an easy way to allow makedatatip work with scatter plots?

??? Error using ==> makedatatip at 57
Objects of class 'specgraph.scattergroup' are not a valid targets for
datatips.

Thanks.

Comment only
15 Apr 2009 Yannick T

Very useful indeed. I don't know why Matlab itself doesn't provide this feature, I spent a lot of time searching the documentation for a way to do this.

23 Jul 2008 Daphne W

Just what I was looking for on the Newsgroup a few months ago. Works perfectly on 2006b as well.
Thanks!

21 May 2008 Ben Kang

Very useful! Sometimes, it's hard to find and select exactly the point, especially for 3-D complex surface.

13 May 2008 John D'Errico

A nice idea. Good help, lots of examples, good error checking, an H1 line. Well done.

Updates
27 Jun 2012 1.1

Included a BSD license.
Updated to allow additional objects including scatter plots and images.

Contact us