Setting the UserData property of a plot with max and min values
9 views (last 30 days)
Show older comments
Hello, I am wanting to normalise a plot (between 0 and 1) with the option of undoing it.
This is my code to perform the normalisation.
ax=app.UIAxes;
[x,y] = getDataFromGraph(app,ax,1); % My function get get the XData & YData of a plot
mx=max(y(:)); mn=min(y(:));
y_normalized = normalize(y, 'range'); % This ensures max and min are 0 and 1
b=ax.Children; % b(1) is last object added to uiaxes
b(1).YData=y_normalized; % Neat way to change data without actully deleting it
% and retains all it properties such as colour
% Add the max and min values of the raw data to userdata
p=b(1) % Get last plot handle
p.UserData % See current value
set(p.UserData,mx) % Set mx
p.UserData % View agin to make sure its what we want
But this is leaving userdata as empty
Tag: ''
Type: 'line'
UserData: []
Visible: on
XData: [1.00 121.00 241.00 361.00 481.00 601.00 721.00 841.00 961.00 1081.00 1201.00 1321.00 1441.00 1561.00 1681.00 1801.00 1921.00 … ] (1×136 double)
XDataMode: 'manual'
What am I doing wrong and how can I include both mx and mn in the userdata entry?
0 Comments
Accepted Answer
See Also
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!