Reputation: 8124
I have two signals, one for each axis and taken singularly and plotted in a standard way separately they would look like this:
However they represent different measurements and I need to superimpose them by representing one on the standard X-Y axis (bottom-left) and one on a different set of coordinate axis (X = left, Y = top).
I thought of the following code:
figure(1);
line(1:128,imagesXMatrix(i,:));
ax1 = gca;
set(ax1,'XColor','r','YColor','r')
ax2 = axes('Position',get(ax1,'Position'), ...
'XAxisLocation','left','YAxisLocation','top', ...
'Color', 'none','XColor','k','YColor','k');
line(1:128,imagesYMatrix(i,:),'Parent',ax2);
but am getting the following error:
Error using axes
Bad property value found.
Object Name: axes Property
Name: 'XAxisLocation'.
which I guess means that value left
is not ok for the XAxisLocation
variable.
What I would really want is simply the superimposition of the two following plots, any idea on how to make it happen?
Thanks a lot!
Upvotes: 2
Views: 2528
Reputation: 25232
plotyy
will do the trick:
figure(1)
AX = plotyy(x1,y1,x2,y2,'plot');
set(get(AX(1),'Ylabel'),'String','y1')
set(get(AX(2),'Ylabel'),'String','y2')
and additional properties like:
set(AX(1),'ylim',[...],...)
set(AX(2),'ylim',[...],...)
and more information in the documentation.
Upvotes: 2