looping thru multiple line data in UIAxes plot and writing all X,Y data to an array
Hello, i have a set of line plots on a UIAxes on a UIFigure using Appdesigner.
Note each plot has differing X coordinates
I want a way to be able to save all these plots so that I can revisit later and add further plots to it.
The approach I was going to take was to access the line objects and loop through assigning each X,Y datat set to a data array that I could save out and then recal at a later date.
ax=app.UIAxes;
L=ax.XLim;
L2=L(2); % Get max number on x-axis
h1 = findall(ax, ‘type’, ‘line’) % Get just line objects for now
n=numel(h1); % Number of line plots (will do text objectes later)
H=nan(L2,2*n) % Create an array of Nans to hold all data (row,cols)
% Each line requires its X data to be saved also
Now loop thru’ all line items and splat the X,Y data to the array
for(i=1:n)
t = h1(i)
H(:,(2*i)-1)=(t.XData)’;
H(:,2*i)=(t.YData)’;
end
H
But Im getting the following error
Unable to perform assignment because the size of the left side is 120-by-1 and the size of the right side is 100-by-1.
Error in GenericDataAnalysis/ReadHeadersButtonPushed (line 533)
H(:,(2*i)-1)=(t.XData)’;
I suspect its to do with non-equal length of data sets. Perhaps I need some sort of padding for the missing data?
This is my current output:
L2 =
120
h1 =
7×1 Line array:
Line (20s Delay)
Line (15s Delay)
Line (9s Delay)
Line (5s Delay)
Line (2s Delay)
Line (FC Top)
Line (FC Btm)
The second part of my question, is whats the best approach to retain the colours and text objects?
Remember, i don’t just want the graphic saved, I want to be able to add data to it later from within my GUI.
Thanks
JasonHello, i have a set of line plots on a UIAxes on a UIFigure using Appdesigner.
Note each plot has differing X coordinates
I want a way to be able to save all these plots so that I can revisit later and add further plots to it.
The approach I was going to take was to access the line objects and loop through assigning each X,Y datat set to a data array that I could save out and then recal at a later date.
ax=app.UIAxes;
L=ax.XLim;
L2=L(2); % Get max number on x-axis
h1 = findall(ax, ‘type’, ‘line’) % Get just line objects for now
n=numel(h1); % Number of line plots (will do text objectes later)
H=nan(L2,2*n) % Create an array of Nans to hold all data (row,cols)
% Each line requires its X data to be saved also
Now loop thru’ all line items and splat the X,Y data to the array
for(i=1:n)
t = h1(i)
H(:,(2*i)-1)=(t.XData)’;
H(:,2*i)=(t.YData)’;
end
H
But Im getting the following error
Unable to perform assignment because the size of the left side is 120-by-1 and the size of the right side is 100-by-1.
Error in GenericDataAnalysis/ReadHeadersButtonPushed (line 533)
H(:,(2*i)-1)=(t.XData)’;
I suspect its to do with non-equal length of data sets. Perhaps I need some sort of padding for the missing data?
This is my current output:
L2 =
120
h1 =
7×1 Line array:
Line (20s Delay)
Line (15s Delay)
Line (9s Delay)
Line (5s Delay)
Line (2s Delay)
Line (FC Top)
Line (FC Btm)
The second part of my question, is whats the best approach to retain the colours and text objects?
Remember, i don’t just want the graphic saved, I want to be able to add data to it later from within my GUI.
Thanks
Jason Hello, i have a set of line plots on a UIAxes on a UIFigure using Appdesigner.
Note each plot has differing X coordinates
I want a way to be able to save all these plots so that I can revisit later and add further plots to it.
The approach I was going to take was to access the line objects and loop through assigning each X,Y datat set to a data array that I could save out and then recal at a later date.
ax=app.UIAxes;
L=ax.XLim;
L2=L(2); % Get max number on x-axis
h1 = findall(ax, ‘type’, ‘line’) % Get just line objects for now
n=numel(h1); % Number of line plots (will do text objectes later)
H=nan(L2,2*n) % Create an array of Nans to hold all data (row,cols)
% Each line requires its X data to be saved also
Now loop thru’ all line items and splat the X,Y data to the array
for(i=1:n)
t = h1(i)
H(:,(2*i)-1)=(t.XData)’;
H(:,2*i)=(t.YData)’;
end
H
But Im getting the following error
Unable to perform assignment because the size of the left side is 120-by-1 and the size of the right side is 100-by-1.
Error in GenericDataAnalysis/ReadHeadersButtonPushed (line 533)
H(:,(2*i)-1)=(t.XData)’;
I suspect its to do with non-equal length of data sets. Perhaps I need some sort of padding for the missing data?
This is my current output:
L2 =
120
h1 =
7×1 Line array:
Line (20s Delay)
Line (15s Delay)
Line (9s Delay)
Line (5s Delay)
Line (2s Delay)
Line (FC Top)
Line (FC Btm)
The second part of my question, is whats the best approach to retain the colours and text objects?
Remember, i don’t just want the graphic saved, I want to be able to add data to it later from within my GUI.
Thanks
Jason uiaxes, plot MATLAB Answers — New Questions