No BSD License  

Highlights from
MAKEDATATIP

4.85714

4.9 | 7 ratings Rate this file 5 Downloads (last 30 days) File Size: 3.63 KB File ID: #19877
image thumbnail

MAKEDATATIP

by Tim Farajian

 

11 May 2008 (Updated 12 May 2008)

Allows programmatically adding datatips to any valid graphical object.

| Watch this File

File Information
Description

MAKEDATATIP allows programmatically adding datatips to graphical objects.

Creation of this function was motivated because I was unable to find any simple built-in method. If there is a better method, I would love to know about it.

Note that this function was only tested in R2007b.

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 submission has inspired the following:
linkdatatips
MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (10)
13 May 2008 John D'Errico

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

21 May 2008 Ben Kang

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

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!

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.

15 Mar 2010 Jason

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.

22 Mar 2010 James Ross

Any chance of posting this using the BSD License?

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.

21 Jun 2011 Ben  
16 Aug 2011 Benjamin  
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.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
annotation Tim Farajian 22 Oct 2008 10:00:31
customization Tim Farajian 22 Oct 2008 10:00:31
data cursor Tim Farajian 22 Oct 2008 10:00:31
datacursor Tim Farajian 22 Oct 2008 10:00:31
create Tim Farajian 22 Oct 2008 10:00:31
datatip Tim Farajian 22 Oct 2008 10:00:31
programmatically Tim Farajian 22 Oct 2008 10:00:31
data tip Tim Farajian 22 Oct 2008 10:00:31
create Marco 22 Aug 2011 11:11:30

Contact us at files@mathworks.com