File Exchange

image thumbnail


version 1.5.0 (49.5 KB) by Massimo Ciacci
A simple tool to create multiple data tips on multiple line handles, with color matched to that of each curve.


Updated 25 May 2020

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

% ADD_DATATIPS( x_values , [h_curve_Array], [fontSize, nx,ny])
% Creates multiple data tips on multiple line handles
% with color matched to that of each curve.
% Tips are created at location xi,fn(xi) where
% xi = x_values,
% fn(xi) = defined by (XData,YData) in h_curve_Array(n)
% ------
% h_curve_Array = a single Line handle or an array of them
% x_values = array of x value where data tips are requested
% fontSize = self explanatory
% nx,ny = nr of digits used for representation x,y(z)

% figure(); hold on;
% p_h(1) = plot(0:10,(0:10).^2,'b');
% p_h(2) = plot(0:10,(0:10),'r');
% add_DataTips( [3.3,5.5,7.7] , p_h, 7)
% figure(); hold on;
% plot(0:10,(0:10).^2,'b');
% plot(0:10,(0:10),'r');
% add_DataTips( [3.3,5.5,7.7])
% M.Ciacci, 2019/11/26, rev1.4

Cite As

Massimo Ciacci (2020). add_DataTips (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Gopher Wood

Excellent work!
A small bug. No matched color of the background of the tip boxes in given demo. Actually, all background colors are gray. My matlab version is 2019a.



Hopefully fixed issue with the background color of the data tips.


Now one can pass empty handles ( h_curve_Array) and the function will fetch them from gca.


Fixed background color with simpler HSL space which preserves hue.


Solved this warning by adding a check on interp position of tip:
Warning: Error updating PointDataTip.
DataSpace or ColorSpace transform method failed"


updated for ML2016b: added drawnow to fix potential error
prevent error when data tip out of current xlims


removed unused old code

MATLAB Release Compatibility
Created with R2016b
Compatible with R2014b to any release
Platform Compatibility
Windows macOS Linux