add_DataTips

A simple tool to create multiple data tips on multiple line handles, with color matched to that of each curve.
518 téléchargements
Mise à jour 1 juil. 2023

Afficher la licence

Note de l’éditeur : 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)
%
% INPUTS:
% ------
% 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)
% set nx=0 if you only want to display y value
% set ny=0 if you only want to display x value
%
% EXAMPLE:
% 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)
%
% EXAMPLE:
% figure(); hold on;
% plot(0:10,(0:10).^2,'b');
% plot(0:10,(0:10),'r');
% add_DataTips( [3.3,5.5,7.7])
%
% EXAMPLE skipping X values (by setting nx = 0)
% figure(); hold on;
% plot(0:10,(0:10).^2,'b');
% plot(0:10,(0:10),'r');
% add_DataTips([3.3,5.5,7.7], [],[] ,0)
%
% EXAMPLE skipping Y values (by setting ny = 0)
% figure(); hold on;
% plot(0:10,(0:10).^2,'b');
% plot(0:10,(0:10),'r');
% add_DataTips([3.3,5.5,7.7], [],[] ,2,0)
%
% M.Ciacci, 2020/03/20, rev1.5
% M.Ciacci, 2020/07/10, rev1.6
% M.Ciacci, 2020/12/03, rev1.7

Citation pour cette source

Massimo Ciacci (2026). add_DataTips (https://fr.mathworks.com/matlabcentral/fileexchange/72849-add_datatips), MATLAB Central File Exchange. Extrait(e) le .

Compatibilité avec les versions de MATLAB
Créé avec R2016b
Compatible avec les versions R2014b et ultérieures
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Display and Exploration dans Help Center et MATLAB Answers
Remerciements

A inspiré : add_DataTips_2D

Version Publié le Notes de version
2.2.0

- Added customDataTipCallBack, Separated update function from creation of data tips
- Added setTips_CallBack to add colored tips by mouse click
- placefig_Normalized no need to know screensize now

2.0.0

cleaned up test bench
added a check for interpolation which would fire error

1.9.2

forgot to include one function

1.9.1

screenshot was not updated ?

1.9.0

Now it is possible to specify a different format per curve.
A new chopY parameter can truncate values close to 0 to exactly 0, on a single data tip, without affecting precision of other data tips.

1.8.0

fixed bug when plot contains only one point

1.7.0

- fixed bug when xdata was not sorted or xvalues upon call
- added feature: can define only X or only Y values on tip
- added feature: when plot handles not given as input, consider stem plots too

1.5.0

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

1.4.0

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

1.3.0

Fixed background color with simpler HSL space which preserves hue.

1.2.0

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

1.1.0

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

1.0.1

removed unused old code

1.0.0