当前位置:网站首页>MATLAB | 基于分块图布局的三纵坐标图绘制
MATLAB | 基于分块图布局的三纵坐标图绘制
2022-06-27 03:34:00 【slandarer】
关于代码
这种图是在公众号「海洋与大气科学」看到的,公众号大哥已经给出了这类图的绘制方式,但是发现在比较新的版本(R2021a及之后),可以使用 tiledlayout 分块图布局更加自然的写出,于是有了这篇推送。对于老版本可以点击下列跳转链接:跳转
完整代码及效果
% 随便生成一组数据
x=0:.05:3*pi;
noise=(rand([1,length(x)])-0.5);
y1=sin(x-2)-5+noise.*.1;
y2=6.*cos(0.5*x)+noise.*.1;
y3=1.5.*sin(x)+0.5.*cos(x)+noise.*.3;
% 创建布局
tdl=tiledlayout(1,10);
% 减小空白区域面积,可删去
tdl.TileSpacing='tight';
tdl.Padding='compact';
% 第一条曲线坐标区域 ==============================
ax1=axes(tdl);hold on
ax1.LineWidth=1.5; % 轴粗细
ax1.YColor='k'; % 轴颜色(k:黑色)
ax1.XLabel.String='x'; % x轴标签:'x'
ax1.YLabel.String='var1'; % y轴标签:'var1'
ax1.Layout.TileSpan=[1 9];% 坐标区域占9/10宽度,第三个y轴占1/10宽度
% 在这进行第 1 组数据绘图- - - - - - - - - - - - -
plot(ax1,x,y1,'k','LineWidth',2)
% 第二条曲线坐标区域 ==============================
% 其他属性与上一坐标区域相似
% 设置Color为'none'
% 可将坐标区域背景设置为透明
% 让之前的绘图不被遮挡
ax2=axes(tdl);hold on
ax2.LineWidth=1.5;
ax2.YAxisLocation='right';
ax2.Color='none';
ax2.YColor='r';
ax2.YLabel.String='var2';
ax2.Layout.TileSpan=[1 9];
% 在这进行第 2 组数据绘图- - - - - - - - - - - - -
plot(ax2,x,y2,'r','LineWidth',2)
% 第三条曲线坐标区域 ==============================
ax3=axes(tdl);hold on
ax3.Color='none';
ax3.YColor='none';
ax3.Layout.TileSpan=[1 9];
% 在这进行第 3 组数据绘图- - - - - - - - - - - - -
plot(ax3,x,y3,'b','LineWidth',2)
% 让坐标区域x轴关联
linkaxes(tdl.Children,'x')
% 绘制第三个y轴,占1/10宽度,颜色为b:蓝色
ax4=axes(tdl,'LineWidth',1.5,'YAxisLocation','right',...
'Color','none','XColor','none');
ax4.YColor='b';
ax4.YLabel.String='var3';
ax4.Layout.Tile='east';
ax4.Layout.Tile=10;
linkaxes([ax3,ax4],'y')

边栏推荐
- PAT甲级 1021 Deepest Root
- Pat grade a 1023 have fun with numbers
- Basic functions of promise [IV. promise source code]
- 流沙画模拟器源码
- 我是怎样简化开源系统中的接口的开发的?
- 敏捷开发篇--Agile Development-自用
- 2021:adavqa: overlapping language priors with adapted margin cosine loss *
- GAMES101作业7提高-微表面材质的实现过程
- Products change the world
- 2016Analyzing the Behavior of Visual Question Answering Models
猜你喜欢

2021:Passage Retrieval for Outside-KnowledgeVisual Question Answering通道检索的外部知识视觉问答

发现一款 JSON 可视化工具神器,太爱了!

Agile development - self use

Super détaillé, 20 000 caractères détaillés, mangez à travers es!

栈溢出漏洞

2021:Check it again:Progressive Visual Question Answering via Visual Entailment通过视觉暗示进行渐进式视觉问答

Network structure and model principle of convolutional neural network (CNN)

Uni-app 之uParse 富文本解析 完美解析富文本!

一文教你Kali信息收集

Implementation of window encryption shell
随机推荐
ESP8266
Career outlook, money outlook and happiness outlook
测试nohup和&的各自作用
Pat grade a 1020 tree Traversals
面试-01
Web development framework - Express (installation and use, static hosting, routing processing, use of Middleware)
fplan-电源规划
Solve the problem of error reporting in cherry pick submission
Pat grade a 1021 deep root
Paddlepaddle 20 implementation and use of exponentialmovingaverage (EMA) (support static graph and dynamic graph)
Pat grade a 1019 general palindromic number
Nacos调用微服务两个问题:1.Load balancer does not contain an instance for the service 2.Connection refused
JMeter takes the result of the previous request as the parameter of the next request
2021:Passage Retrieval for Outside-KnowledgeVisual Question Answering通道检索的外部知识视觉问答
2016Analyzing the Behavior of Visual Question Answering Models
Servlet and JSP final review examination site sorting 42 questions and 42 answers
pytorch_ grad_ Cam -- visual Library of class activation mapping (CAM) under pytorch
NestJS环境变量配置,解决如何在拦截器(interceptor)注入服务(service)的问题
Pat class a 1024 palindromic number
[promise I] introduction of promise and key issues of hand rolling