I'm trying to plot a line graph and a bar graph on the same y-axis:
figure;
plotyy(Pert, Rfootvel(:,i+1), Pert, 0,'bar','plot');
hold(ax(1), 'on');
legend('Pert 1-8', 'Base');
ylim(ax(2), [0 1]);
title(['The avg pert velocity of the first step vs the avg base velocity, PP' num2str(j)]);
Unfortunately, setting the second y-axis limit like this doesn't affect the second y-axis. Matlab simply does what it thinks is best. However, I need to directly compare the two, so the axes need to be the same. Can anyone help here?
In order to use
ax(n)
you need to provide plotyy with the right output arguments. In your case, you could use the following: