Graph Updates but does not display Line

2 views (last 30 days)
Lawson Hoover
Lawson Hoover on 8 Jan 2013
When I run this code to update the graph in an animation like manner, the axis of the graph updates, indicating that the new data has been received, but the new line is not plotted. It is as almost like everything is working but the color does not appear.
plot(x,y,'--r','LineWidth',3); % original position
xlabel('Beam Length (in.)','Color','b');
%ylim([-(Beam.y(10)) max(Beam.y)]);
xZero = 0;
yZero = 0;
hold on % hold the orginal position plot and the axes properties
M(100) = struct('cdata',[], 'colormap', []); % preinitialization
ht = plot(xZero,yZero,'-b','linewidth',2); % new position
set(ht ,'XDataSource','Beam.x') % Sets the data source for plot ht
for a1 = 1:100
for i = 1:100 % Plots each new position on the graph
M(a1) = getframe(gcf); %The plot seems to adjust proeperly

Answers (1)

Ryan Livingston
Ryan Livingston on 8 Jan 2013
I wasn't able to run your code due to some undefined variables but here are a few thoughts:
is specified as the linespec which will plot a tiny dot on the axes. Could you try:
to plot a larger marker and see if that moves?
- When calling set(ht, 'XData'...) it seems that each new plot will be a single point. Is this what you wanted or did you want to accumulate the points? - If these don't help could you please post a code snippet which has all the variables defined and runs on its own?
Ryan Livingston
Ryan Livingston on 9 Jan 2013
That helps a bit. My assumption is that:
Beam.x(i), Beam.y(a1,i)
are scalars, is that correct? In that case, a single point is being plotted rather than a line.
If you would like to plot one row of y versus x then does something like:
for a1 = 1:100
M(a1) = getframe(gcf); %The plot seems to adjust properly
do more what you are looking for rather than the two nested loops?

Sign in to comment.


Find more on Graphics Performance 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!

Translated by