using plotyy for multiple plots
5 次查看(过去 30 天)
显示 更早的评论
I have four plots, to be plotted in the same figure. Two plots are for a y-axis on the right hand side and two for the left hand side. for each pair, the x values are different. For example:
% Two plots for y at right axis
x1 = 0:10;
x2 = 0:5;
y1 = rand(1,11);
y2 = rand(1,6);
% Two plots for y at left axis
x3 = 0:10;
x4 = 0:5;
y3 = rand(1,11);
y4 = rand(1,6);
How can I plot them in a same figure with plotyy or any other command?
Thanks, :)
Soroush
0 个评论
回答(1 个)
Walter Roberson
2015-7-16
ax = plotyy(x3, y3, x1, y1); %left then right
line(ax(1), x4, y4); %add another line to left axis
line(ax(2), x2, y2); %add another line to right axis
2 个评论
Walter Roberson
2015-7-16
ax = plotyy(x3, y3, x1, y1); %left then right
line(x4, y4, 'Parent', ax(1)); %add another line to left axis
line(x2, y2, 'Parent', ax(2)); %add another line to right axis
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Two y-axis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!