%% Change Labels and Add Row
% Modify the contents of data tips on a scatter plot. First, load sample accident data and create the scatter plot. Then, create a data tip interactively or by using the datatip function. By default, data tips show the coordinates of the data point.

load('accidents.mat','hwydata','statelabel')
s = scatter(hwydata(:,5),hwydata(:,4));
dt = datatip(s,11246.7,1493);

%
% Change the data tip labels from X and Y to Drivers (in thousands) and Fatalities by accessing the DataTipTemplate property of the plotted object and setting the Label properties.

s.DataTipTemplate.DataTipRows(1).Label = 'Drivers (in thousands)';
s.DataTipTemplate.DataTipRows(2).Label = 'Fatalities'; 

% Add a new row to the data tip. For the label, use State. For the value, use the state names contained in the statelabel variable in your workspace.

row = dataTipTextRow('State',statelabel);
s.DataTipTemplate.DataTipRows(end+1) = row;

% Copyright 2019 The MathWorks, Inc.