%% Show Table Values in Data Tips
% Modify the contents of data tips for a scatter plot to include values from a table. First, create a table from a sample spreadsheet of patient data. Plot the data. Then, create a data tip interactively or by using the datatip function.

tbl = readtable('patients.xls');
s = scatter(tbl.Height,tbl.Weight);
dt = datatip(s,64,142);

% Change the data tip labels from X and Y to Height and Weight. Then, add a new row to the data tip that uses the label Age and shows the values from the Age column of the table.

s.DataTipTemplate.DataTipRows(1).Label = 'Height';
s.DataTipTemplate.DataTipRows(2).Label = 'Weight';
row = dataTipTextRow('Age',tbl.Age);
s.DataTipTemplate.DataTipRows(end+1) = row;

% If you are using R2018b or earlier, customize the data tips by setting the UpdateFcn property of the datacursormode object instead of using the DataTipTemplate object.
% Copyright 2019 The MathWorks, Inc.