%% Update Plot by Modifying the Table
% When you pass a table to a plotting function, a copy of the table is stored in the SourceTable property of the plot object. If you change the contents of the table stored in that property, the plot is automatically updated to show the changes.
% Read patients.xls as a table and plot the Weight variable versus the Height variable. Return the Scatter object as s, so you can access its properties later.

tbl = readtable("patients.xls");
figure
s = scatter(tbl,"Height","Weight","filled");

%
% To change a value in the table, use dot notation to reference the table from the SourceTable property of the Scatter object. In this case, find the maximum value of the Weight variable and change it to 300. The plot is automatically updated.
% Note: Making changes to a table in your workspace has no effect on the plot.

[~,idx] = max(s.SourceTable.Weight);
s.SourceTable.Weight(idx) = 300;

% Copyright 2020 The MathWorks, Inc.