Penguin Zhou
Penguin Zhou

Reputation: 131

Hold one does not work for two plot handle having he same axeshandle

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.

Upvotes: 2

Views: 62

Answers (2)

Penguin Zhou
Penguin Zhou

Reputation: 131

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)); 

Upvotes: 0

Mendi Barel
Mendi Barel

Reputation: 3677

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

Upvotes: 3

Related Questions