%% Change Format for Displayed Values
% Create a line plot of sine values. Add a third row to the default data tips to show the cosine values. Specify the numeric format for the displayed cosine values. In this case, use '%+4.4g' to include the sign character (+) for positive values. After you create the new row, add it to the DataTipTemplate property for the Line object.

x = linspace(0,10);
y1 = sin(x);
y2 = cos(x);
p = plot(x,y1);
row = dataTipTextRow('Cosine',y2,'%+4.4g');
p.DataTipTemplate.DataTipRows(end+1) = row;

% Create a data tip interactively or by using the datatip function.

dt = datatip(p,6.56566,0.27873);

% Copyright 2019 The MathWorks, Inc.