Matlab 多个图像共用一个横坐标 subplot、plotyy

x=0:0.1:7;

h1=subplot(3,1,1);

plot(x,sin(x),'k');

h2=subplot(3,1,2);

plot(x,cos(x),'k');

set([h1,h2],'Xcolor','w','XTick',[]) %将前两个x坐标设为白色,且不显示xtick

% 利用plotyy双轴显示同一个图像,一副显示左y,下x,另一幅显示右y,下x

h3=subplot(3,1,3);

[ax,h4,h5]=plotyy(x,sec(x),x,sec(x));

box off

set(ax(1),'YColor','k')%k 黑色

set(ax(2),'Xaxislocation','bottom','YColor','k')

set(h5,'color','k')

set(gcf,'color','w') % 背景色设为白色,间接隐藏所有白色轴线

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

x = 0:0.01:20;

y1 = 200*exp(-0.05*x).*sin(x);

y2 = 0.8*exp(-0.5*x).*sin(10*x);

[AX,H1,H2] =

plotyy(x,y1,x,y2,'plot');ylabel('First

axes1');

set(AX(1),'ylim',[-300 300]); %

坐标轴范围

set(AX(1),'ytick',[-300:100:300])

%坐标轴刻度 划分这么多个范围 set(AX(1),'yticklabel',[-300:100:300])

set(AX(1),'box','off')

set(get(AX(2),'ylabel'),'string','Second axes2');

set(AX(2),'ylim',[-1 1]);

set(AX(2),'ytick',[-1:.5:1])

set(AX(2),'yticklabel',[-1:.5:1])

set(AX(2),'xaxislocation','top')%%%%%%%%%%坐标轴位置

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

在金融数据作图中像一般的统计分析图一样在横坐标标出日期,可按您的书中提到的方法我只能把日期叠加到原来的数字上,而且用尽办法也去不掉原来的数字。比如代码如下,横坐标的1

2 3 4 5怎么也去不掉并用日期代替,请赐教

A=[1 2 3 4 5]; B=[2 4 6 8

10];

plotyy(1:5,A,1:5,B,'plot');

set(gca,'XTick',[1 2 3 4 5]);

set(gca,'XTickLabel',{'2005-01', '2005-07','2006-01',

'2006-07','2007-01'});

如图 横坐标有数字与重叠 去不掉 因为有两个x轴的缘故

修改后:

A=[1 2 3 4 5]; B=[2 4 6 8

10];

[AX H1 H2]=plotyy(1:5,A,1:5,B,'plot');

set(AX,'XTick',[1 2 3 4 5]); %

相当于刻度坐标轴 不是让其自带控制大小set(AX,'XTickLabel',{'2005-01',

'2005-07','2006-01', '2006-07','2007-01'});

%% 举例说明 XTick

A=[1 2 3 4 5]; B=[2 4 6 8 10];

[AX H1 H2]=plotyy(1:5,A,1:5,B,'plot');

set(AX,'XTick',[1 2 3 4 5]);

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

matlab plotyy xtick的横坐标的设置问题

[AX,H1,H2] = plotyy(24,0,0,0,'plot');

set(AX(1),'XColor','k','YColor','b');

set(AX(2),'XColor','k','YColor','r');

set(get(AX(1),'Ylabel'),'String','Plasma Glucose (mg/dl)')

set(get(AX(2),'Ylabel'),'String','Plasma Insulin (pmol/l)')

set(AX(1),'ylim',[50 250])

set(AX(2),'ylim',[0 600])

set(AX(1),'ytick',50:50:250)

set(AX(2),'ytick',0:100:600)

set(gca,'xlim',[0 24])

set(gca,'xtick',0:2:24)

grid on

xlabel('Time (hour)')

目的是想让左边的纵坐标范围为50-250,右边的纵坐标范围为0-600,横坐标范围为0-24

现在出来的图纵坐标没问题,但横坐标很乱,不知为什么。请高人指教。

倒数第三第四句:

set(gca,'xlim',[0 24])

set(gca,'xtick',0:2:24)

改成:

set(AX,'xlim',[0 24])

set(AX,'xtick',0:2:24)

原因:

这里有两个x轴,因此需要将两个的axes的x坐标设置成一样的才行

这些关键在于设置句柄

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

双纵坐标的标注已实现

[AX]=plotyy(x1,y1,x1,y2);

set(get(AX(1),'Ylabel'),'string','left

Y-axis‘);

set(get(AX(2),'Ylabel'),'string','right

y-axis');

了解plotyy的返回值

[AX]=plotyy(x1,y1,x1,y2);

得到两个axes句柄,AX(1)和AX(2)

set(AX(1),'yTick',[0:10:350]) 设置左边Y轴的刻度

set(AX(2),'yTick',[0:10:350]) 设置右边Y轴的刻度

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

双y坐标实例

close all hidden

clear all

clc

% w=boxcar(nfft);

fni1=input('请输入时间序列文件: ','s');

fid1=fopen(fni1,'r');

s=fscanf(fid1,'%s',1);

if same(s,'Curve')

for

i=1:61

tline=fgetl(fid1);

end

else

fid1=fopen(fni1,'r');

end

a1=fscanf(fid1,'%f');

status=fclose(fid1);

n=length(a1);

n2=n/2;

a2=reshape(a1,2,n2);

x1=a2(1,:);

y1=a2(2,:);

fni2=input('输入速度曲线文件','s');

fid2=fopen(fni2,'r');

b=fscanf(fid2,'%f');

n3=length(b);

n4=n3/2;

b2=reshape(b,2,n4);

x2=b2(1,:);

y2=b2(2,:);

p=polyfit(x2,y2,3);

y3=polyval(p,x2);

% plot(x2,y2)

[AX,H1,H2]=plotyy(x1,y1,x2,y3);

grid on;

xlabel('时间/s');

set(get(AX(1),'Ylabel'),'string','加速度/g');

set(get(AX(2),'Ylabel'),'string','速度km/h');

set(AX(1),'yTick',[-2:0.5:2]);

% % axes1 = axes('Position',[0.08 0.73 0.38

0.25],'Parent',figure1);

% axis(axes1,[0 xtime(end) -0.5 0.5]);

% set(AX(2),'YTick',[300:5:350]);

yticks2 = linspace(300,360,9);

set(AX(2),'YLim',[300 360],'YTick',yticks2);

set(H2,'linewidth',3);

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=

x = 0:0.01:20;

y1 = 200*exp(-0.05*x).*sin(x);

y2 = 0.8*exp(-0.5*x).*sin(10*x);

[AX,H1,H2] = plotyy(x,y1,x,y2,'plot');

set(AX(1),'XColor','k','YColor','b');

set(AX(2),'XColor','k','YColor','r');

HH1=get(AX(1),'Ylabel');

set(HH1,'String','Left Y-axis');

set(HH1,'color','b');

HH2=get(AX(2),'Ylabel');

set(HH2,'String','Right Y-axis');

set(HH2,'color','r');

set(H1,'LineStyle','-');

set(H1,'color','b');

set(H2,'LineStyle',':');

set(H2,'color','r');

legend([H1,H2],{'y1 =

200*exp(-0.05*x).*sin(x)';'y2 =

0.8*exp(-0.5*x).*sin(10*x)'});

xlabel('Zero to 20 musec.');

title('Labeling plotyy');

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

用[AX,H1,H2]=plotyy(x,y1,x,y2);命令。AX(1),AX(2)分别为左右Y轴的句柄

%%You can use the handles returned by plotyy to label the axes and

set the line styles used for plotting.

%%With the axes handles you can specify the YLabel properties of

the left- and right-side y-axis:

set(get(AX(1),'Ylabel'),'String','Slow Decay')

set(get(AX(2),'Ylabel'),'String','Fast Decay')

%%Use the xlabel and title commands to label the x-axis and add a

title:

xlabel('Time (musec)')

title('Multiple Decay Rates')

%%Use the line handles to set the LineStyle properties of the left-

and right-side plots:

set(H1,'LineStyle','--')

set(H2,'LineStyle',':')

、++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

linspace(0,2*pi,40) % 0到2pi之间布 40个点 生成1*40的行向量

legend([h1,h2,h3],'a','b','c');

这块用曲线的句柄给曲线进行标注 。这种方法允许挑选任意几条标注,而不用按着画图的顺序来。

Plotyy(x1,y1,x2,y2,

'function1','function2')------功能同上,function是指那些

绘图函数如:plot,semilogx,

loglog等. ...

matlab plotyy 横坐标,[转载]关于plotyy的坐标轴 设置相关推荐

  1. matlab 控制命令,[转载]Matlab绘图基本控制命令

    图形的控制与表现 (Figure control and representation) MATLAB提供的用于图形控制的函数和命令: axis: 人工选择坐标轴尺寸. clf:清图形窗口. ginp ...

  2. matlab计算macd_[转载]4.K线图以及常用技术指标的Matlab实现-基于Matlab的量化投资...

    本次主要讲解用Matlab来实现K线图以及常用的技术指标. 相关前导帖子浏览: 系列帖子目录 Matlab的Bar图中Bar颜色灵活设置的一点总结[by faruto] [原创]坐标轴刻度标签旋转升级 ...

  3. matlab的技术指标,[转载]4.K线图以及常用技术指标的Matlab实现-基于Matl

    本次主要讲解用Matlab来实现K线图以及常用的技术指标. 相关前导帖子浏览: 系列帖子目录 Matlab的Bar图中Bar颜色灵活设置的一点总结[by faruto] [原创]坐标轴刻度标签旋转升级 ...

  4. matlab. set坐标轴,matlab绘图坐标轴设置

    matlab坐标轴设置: 简单的曲线:y=sin(x); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% x=-pi/2:0.01:pi/2; y=sin(x); plot(x, ...

  5. MATLAB的GUI界面不显示XY坐标轴

    在GUI中创建一个坐标轴,默认会显示XY坐标,如下图: 如何关闭XY坐标轴呢? 首先在打开GUI界面,双击该坐标轴,在Xcolor和Ycolor中选择白色,将坐标轴设置为白色: 然后在xticklab ...

  6. 最最最全的MATLAB三维柱坐标绘图bar3的坐标轴各种设置

    我想用自己的数据画出下图这样类似的三维柱坐标图. 买家秀: 卖家秀: 画完还是挺满意的,花了不少时间调整图形... 完整代码: data = [1 2 3 4 51 2 3 4 51 2 3 4 51 ...

  7. qchart 坐标轴设置_QChart学习之QValueAxis坐标轴设置

    QChart 坐标轴设置 // 添加轴 QValueAxis *xAxis = new QValueAxis(); QValueAxis *yAxis = new QValueAxis(); // 坐 ...

  8. R可视化使用ggplot2将坐标轴设置为对数坐标轴(Log Scale)

    R可视化使用ggplot2将坐标轴设置为对数坐标轴(Log Scale) 目录 R可视化使用ggplot2将坐标轴设置为对数坐标轴(Log Scale)

  9. python plot设置坐标轴_python matplotlib坐标轴设置的方法

    在使用matplotlib模块时画坐标图时,往往需要对坐标轴设置很多参数,这些参数包括横纵坐标轴范围.坐标轴刻度大小.坐标轴名称等 在matplotlib中包含了很多函数,用来对这些参数进行设置. 我 ...

  10. python 设置x轴_python matplotlib坐标轴设置的方法

    在使用matplotlib模块时画坐标图时,往往需要对坐标轴设置很多参数,这些参数包括横纵坐标轴范围.坐标轴刻度大小.坐标轴名称等 在matplotlib中包含了很多函数,用来对这些参数进行设置. 我 ...

最新文章

  1. 微信小程序-锚点定位+内容滑动控制导航选中
  2. 算法--------旋转数组
  3. 每天睡4小时上7门课
  4. mysql数据库基础(密码策略)
  5. ubuntu  输入时弹出剪切板候选项
  6. SQLServer自增变量修复
  7. Linux 后台执行脚本或命令 nohup
  8. 棋盘问题 ( POJ -1321 )(简单DFS)
  9. 没有副业的人,太难了。。。
  10. xsl判断节点存在_[剑指offer]25删除链表中重复的节点
  11. 练字和平时写字完全不一样怎么办?
  12. iir滤波器c语言程序,请教C语言做iir滤波器问题
  13. 从陈磊接棒后首份财报看拼多多农业版图2.0
  14. 电商项目day09(网站前台之广告功能实现优化策略)
  15. python小玩意——破解wifi数字密码
  16. 计算机应用在医学领域有哪些,计算机在医学领域的应用|网络安全技术
  17. python quit()讲解_Python locals.QUIT属性代码示例
  18. sql实现按小时统计查询
  19. 石油大学c语言上机答案,中国石油大学C语言上机题答案(2015版)答案_最全最详细.docx...
  20. android手机配什么蓝牙耳机,安卓手机配什么蓝牙耳机好?安卓系统蓝牙耳机推荐!...

热门文章

  1. Django 字段选项之 related_name 和 related_query_name
  2. java 金额数字转换大写算法
  3. ESP32实战小项目-小气象站
  4. android高仿ios11系统,安卓仿苹果iOS11主题APP
  5. 【大兴区亦庄亦庄线东晶国际4居室】自如网
  6. 畅游或将私有化退市股价涨近50%,搜狐“吃饱”后能重回巅峰吗?
  7. 微信改微信号连接服务器,微信修改不了微信号怎么回事 微信号怎么修改
  8. 上海安陆FPGA程序下载
  9. 什么是SVC?AVC和SVC有什么区别
  10. 谷歌的现实、摩托的无奈与联想的接盘