version 1.0.4 (479 KB) by Massimo Ciacci
Creates multiple data tips on surface objects of active figure.


Updated 23 Apr 2021

View License

ADD_DATATIPS_2D( x_values , x_values, [fontSize, nxy,nz, matchBckgnd, Alpha])
Creates multiple data tips on all surface handles of gcf.

Tips are created at location (xi,yi), fn(xi,yi) where
xi = x_values, yi = y_values,
fn(xi,yi) = defined by (XData,YData,ZData) in current surface plot

OPTIONS, descriptive
matchBckgnd: Data tip background can be optionally matched in color to that of each surface at the location of the data tip.
nxy,nz : Data tip accuracy in nr of digits for xy and z. 0 means skip.
Alpha : Data tip Transparency.

INPUTS, detailed:
x_values = array of x value where data tips are requested
y_values = array of y value where data tips are requested
fontSize = self explanatory
nxy,nz = nr of digits used for representation x,y,z
set nxy=0 if you only want to display z value
set nz=0 if you only want to display x value
matchBckgnd = (0,1,2) specifies if DataTip bckgnd should be same color as surface @ that point
0 : fixed background light
1 : match color of surf @ point of data tip
2 : match color of surf @ point of data tip, brighter

Alpha = Data tip Transparency

[X,Y,Z] = peaks(25);
surf(X,Y,Z); axis tight; xlabel('x');ylabel('y')
[~,idxM]=max(Z(:)); [~,idxm]=min(Z(:));
[iyM,ixM] = ind2sub(size(Z),idxM);
[iym,ixm] = ind2sub(size(Z),idxm);
x1 = X(1,ixM); x2=X(1,ixm);
y1 = Y(iyM,1); y2=Y(iym,1);
xV = [x1,x2];
yV = [y1,y2];

[h_Dtip_out, zVals] = add_DataTips_2D(xV,yV)
%[h_Dtip_out, zVals] = add_DataTips_2D(xV,yV,14, 0,5, 0);

M.Ciacci, 2021/04/21, rev1.0

Cite As

Massimo Ciacci (2022). add_DataTips_2D (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Inspired by: add_DataTips

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!