在Matlab中绘制多个序列 [英] Plotting multiple series in matlab

查看:122
本文介绍了在Matlab中绘制多个序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下命令会产生一些非常奇怪的结果-

The following commands produce some very strange results -

 plotyy(1:3,2:4,3:5,4:6)
hold on
plotyy(1:3,2.1:4.1,3:5,4.1:6.1)

我基本上想在左y轴上绘制两个不同的序列,并在右y轴上绘制另外两个序列.上面的命令对于左边的系列工作正常,但是对于右边的系列却产生奇怪的结果.第二条绿线看起来不应该.

I basically want to plot two different series on the left y axes and two more series on the right y axes. The above commands work fine for the left series, but produce weird results for the right one. The second green line doesn't look like it should.

推荐答案

您遇到的问题与plotyy创建图的方式有关. plotyy创建两个不同的坐标轴,然后将它们安装到单个图形中.发出hold on命令时,仅冻结了其中一个轴.要解决此问题,您需要单独握住每个对象,然后使用plot命令重新绘制在它们上.

The problem that you are having is related to the way that the plotyy creates they plot. plotyy creates two different axes that it plots on, and then mounts them into a single figure. When you issue the hold on command, you are only freezing one of the axes. To fix this, you need to hold each one individually, and then plot back onto them using the plot command.

[ax,hl,hr] = plotyy(1:3,2:4,3:5,4:6);
hold(ax(1), 'on')  
hold(ax(2), 'on')
plot(ax(1), 1:3,2.1:4.1) 
plot(ax(2), 3:5,4.1:6.1)

这篇关于在Matlab中绘制多个序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆