2

Here is how I get two plot handler which will draw on the same graphic(axes).

figureHandle = figure('NumberTitle','off',...
'Name','RFID Characteristics',...
'Color',[0 0 0],'Visible','off');

axesHandle = axes('Parent',figureHandle,...
        'YGrid','on',...
        'YColor',[0.9725 0.9725 0.9725],...
        'XGrid','on',...
        'XColor',[0.9725 0.9725 0.9725],...
            'Color',[0 0 0]);
hold on;
xData = 0; yData=0;
plotHandle1 = plot(axesHandle,xData,yData,'Marker','.','LineWidth',1,'Color',[0 1 0]);
plotHandle2 = plot(axesHandle,xData,yData,'Marker','.','LineWidth',1,'Color',[1 0 0]);

This is how I recursively use to draw real-time data.

    set(plotHandle1,'YData',newestTag2Data(5,:),'XData',newestTag2Data(1,:));
    hold on
    set(plotHandle2,'YData',newestTag3Data(5,:),'XData',newestTag3Data(1,:));
    hold off
    set(figureHandle,'Visible','on');
    drawnow;

However, I only see the plotHandle2, not plotHandle1.

Seems hold on does not work here.

Penguin Zhou
  • 131
  • 2
  • 10

2 Answers2

3

hold on works on active axes, to hold your specific axes use:

hold(axesHandle,'on')

You can make sure that you got 2 plots if you look at:

axesHandle.Children
Mendi Barel
  • 3,350
  • 1
  • 23
  • 24
0

Just a quick add up.

You can use

get(axesHandle.Children);

to see all the properties of the line on the axesHandle.

If you have multiple lines on one axesHandle, use

get(axesHandle.Children(1));
get(axesHandle.Children(2)); 
Penguin Zhou
  • 131
  • 2
  • 10