MATLAB 绘制折线图

article/2025/9/19 2:55:06

MATLAB 绘制折线图


在这里插入图片描述

想要绘制出如上图所示折线图,首先,先展示代码:

x=0:10:50;
a=[0, 1.80,7.60,17.40,31.20,49.00]
plot(x,a,'s-g','MarkerSize',2,'MarkerFaceColor','g','MarkerEdgeColor','g','LineWidth',2);
grid
b=[0,1.10,4.20,9.30,16.40,25.50];
hold on
plot(x,b,'s-y','MarkerSize',2,'MarkerFaceColor','y','MarkerEdgeColor','y','LineWidth',2);
c=[0,1.10,4.20,9.30,16.40,25.50];
hold on
plot(x,c,'+-b','MarkerSize',1.5,'MarkerFaceColor','b','MarkerEdgeColor','b','LineWidth',1.5);
d=[0,0.20,0.40,0.60,0.80,1.00]
hold on
plot(x,d,'s-k','MarkerSize',2,'MarkerFaceColor','k','MarkerEdgeColor','k','LineWidth',2);
e=[0,0.10,0.20,0.30,0.40,0.50]
hold on
plot(x,e,'s-r','MarkerSize',2,'MarkerFaceColor','r','MarkerEdgeColor','r','LineWidth',2)
xlabel('Number of participant','fontsize',22,'FontWeight','bold','FontName','Times New Roman') 
ylabel('Number of transmission   x10^3','fontsize',21,'FontWeight','bold','FontName','Times New Roman')
h=legend('LGHW13','HSXL16','CM17','HSL17','Ours',loc = 0)
set(h,'Fontsize',16,'FontWeight','bold','FontName','Times New Roman');
set(gca,'FontSize',20,'LineWid',2);%设置坐标轴字体打下以及网格粗细
  1. 设置x轴的数值:0到50 ,间隔为10
  2. a相当于第一个函数y值,b第二个函数y值,依次类推。
  3. grid 是绘制后面的格子,grid on 有格子,grid off 没有格子
  4. plot 是开始绘制,前两个参数是x 和y, 第三个参数是曲线的样式颜色,第四个是说曲线上的方块圆等的大小,下一个是说标志点的内填充颜色,下一个是边缘填充颜色。
    在这里插入图片描述
  5. xlabel 是设置x坐标轴标题的,包括文字的内容,大小,样式等等。
  6. ylabel 是设置y坐标轴标题的,
  7. 设置legend图例 ,其中的loc表示图例的位置,这个需要自己试试。
'best'         : 0, (only implemented for axes legends)(自适应方式)
'upper right'  : 1,
'upper left'   : 2,
'lower left'   : 3,
'lower right'  : 4,
'right'        : 5,
'center left'  : 6,
'center right' : 7,
'lower center' : 8,
'upper center' : 9,
'center'       : 10,
--------------------- 
原文:https://blog.csdn.net/You_are_my_dream/article/details/53440964 
  1. 图例中一行set是对图例中文字的说明。
  2. 最后一行是设置坐标轴上刻度字体大小,LineWid 是设置网格的粗细。
附上论文中两图代码,以供回忆
x=0:10:50;
a=[0,
1.80,
7.60,
17.40,
31.20,
49.00]
plot(x,a,'s-g','MarkerSize',2,'MarkerFaceColor','g','MarkerEdgeColor','g','LineWidth',2);grid
b=[0,
1.10,
4.20,
9.30,
16.40,
25.50];
hold on
plot(x,b,'s-y','MarkerSize',2,'MarkerFaceColor','y','MarkerEdgeColor','y','LineWidth',2);
c=[0,
1.10,
4.20,
9.30,
16.40,
25.50
];
hold on
plot(x,c,'+-b','MarkerSize',1.5,'MarkerFaceColor','b','MarkerEdgeColor','b','LineWidth',1.5);
d=[0,
0.20,
0.40,
0.60,
0.80,
1.00
]
hold on
plot(x,d,'s-k','MarkerSize',2,'MarkerFaceColor','k','MarkerEdgeColor','k','LineWidth',2);
e=[0,
0.10,
0.20,
0.30,
0.40,
0.50
]
hold onplot(x,e,'s-r','MarkerSize',2,'MarkerFaceColor','r','MarkerEdgeColor','r','LineWidth',2)
xlabel('Number of participant','fontsize',22,'FontWeight','bold','FontName','Times New Roman') 
ylabel('Number of transmission   x10^3','fontsize',21,'FontWeight','bold','FontName','Times New Roman')
h=legend('LGHW13','HSXL16','CM17','HSL17','Ours','FontSize',12,loc = 0)
set(h,'Fontsize',16,'FontWeight','bold','FontName','Times New Roman');
set(gca,'FontSize',20,'LineWid',2);%设置坐标轴字体打下以及网格粗细x=0:10:50;
a=[0,
1.80,
7.60,
17.40,
31.20,
49.00]
plot(x,a,'s-g','MarkerSize',2,'MarkerFaceColor','g','MarkerEdgeColor','g','LineWidth',2);
grid on
b=[0,
1.10,
4.20,
9.30,
16.40,
25.50];
hold on
plot(x,b,'s-y','MarkerSize',2,'MarkerFaceColor','y','MarkerEdgeColor','y','LineWidth',2);
c=[0,
1.10,
4.20,
9.30,
16.40,
25.50
];
hold on
plot(x,c,'+-b','MarkerSize',1.5,'MarkerFaceColor','b','MarkerEdgeColor','b','LineWidth',1.5);
d=[0,
0.20,
0.40,
0.60,
0.80,
1.00]
hold on
plot(x,d,'s-k','MarkerSize',2,'MarkerFaceColor','k','MarkerEdgeColor','k','LineWidth',2);
e=[0.5
0.055
0.105
0.155
0.205
0.255]
hold on
plot(x,e,'s-r','MarkerSize',2,'MarkerFaceColor','r','MarkerEdgeColor','r','LineWidth',2)
xlabel('Number of participant','fontsize',22,'FontWeight','bold','FontName','Times New Roman') 
ylabel('Number of measurement x10^3','fontsize',21,'FontWeight','bold','FontName','Times New Roman')
h=legend('LGHW13','HSXL16','CM17','HSL17','Ours','FontSize',12,loc = 0)
set(h,'Fontsize',16,'FontWeight','bold','FontName','Times New Roman');
set(gca,'FontSize',20,'LineWid',2);修改后的第二个x=0:10:50;
a=[0,
1.80,
7.60,
17.40,
31.20,
49.00]
plot(x,a,'s-g','MarkerSize',2,'MarkerFaceColor','g','MarkerEdgeColor','g','LineWidth',2);
grid on
b=[0,
1.10,
4.20,
9.30,
16.40,
25.50];
hold on
plot(x,b,'s-m','MarkerSize',2,'MarkerFaceColor','m','MarkerEdgeColor','m','LineWidth',2);
c=[0,
1.10,
4.20,
9.30,
16.40,
25.50
];
hold on
plot(x,c,'+-b','MarkerSize',1.5,'MarkerFaceColor','b','MarkerEdgeColor','b','LineWidth',1.5);
d=[0,
0.20,
0.40,
0.60,
0.80,
1.00]
hold on
plot(x,d,'s-c','MarkerSize',2,'MarkerFaceColor','c','MarkerEdgeColor','c','LineWidth',2);
e=[0.5
0.055
0.105
0.155
0.205
0.255]
hold on
plot(x,e,'s-r','MarkerSize',2,'MarkerFaceColor','r','MarkerEdgeColor','r','LineWidth',2)
xlabel('Number of participant','fontsize',22,'FontWeight','bold','FontName','Times New Roman') 
ylabel('Number of measurement x10^3','fontsize',21,'FontWeight','bold','FontName','Times New Roman')
h=legend('LGHW13','HSXL16','CM17','HSL17','Ours','FontSize',12,loc = 0)
set(h,'Fontsize',16,'FontWeight','bold','FontName','Times New Roman');
set(gca,'FontSize',20,'LineWid',2);

在这里插入图片描述在这里插入图片描述


http://chatgpt.dhexx.cn/article/TZpW2WeJ.shtml

相关文章

MATLAB绘制统计折线图

MATLAB绘制实验数据折现图 在论文或者文章写作中,经常需要使用图形来表示我们的实验结果。一般来说,这种表示方式比表格更加直观、更加可视化。因此,本文给出一种使用MATLAB处理数据得到折线图的教程。 1. 待处理数据形式 待处理的数据为迭代…

MATLAB中画折线图:plot函数的简单用法

20年4月24日更新 关于MATLAB里柱状图的画法,以及如何在图例legend和轴标签xlabel里加入latex公式,请参考 https://blog.csdn.net/u014261408/article/details/102511989。 使用plot绘制二维图像 MATLAB中plot函数常常被用于绘制各种二维图像&#xff…

matlab 画折线图

针对这篇博客里有些不够详细的地方,后期又写了一个稍微更详细的MATLAB画折线图:https://blog.csdn.net/Rhiney_97/article/details/105000137 代码: 效果图: x1:1:5就是x轴上的数据,从1开始到5结束(即应该有…

MATLAB编程:绘制折线图 以及 画图的一些小技巧

MATLAB编程:绘制折线图 以及 画图的一些小技巧 前言一、介绍二、MATLAB实现三、总结 前言 本博主使用的MATLAB版本是2020b,这个版本可以使用许多有趣的扩展APP。本节将会对如何在已有数据条件下绘制一幅折线图,非常详尽地一种编程方式&#x…

matlab-画折线图

用matlab画折线图是一个很基本的操作,下面是程序 x5:5:50;%x从5开始,50结束,间隔为5a[75.226,76.704,75.263,75.337,75.599,76.302,74.824,76.924,75.595,75.442];b[72.112,70.764,68.63,68.201,64.067,61.717,61.476,61.561,61.066,61.586];plot(x,a,*…

Matlab绘制折线图详细方法

Matlab绘制折线图属于非常基本的功能,首先给出一个示例代码,有详细的解释,可以根据自己需求进行修改。 x1:1:5;%x轴上的数据,第一个值代表数据开始,第二个值代表间隔,第三个值代表终止a[203.024,113.857,2…

matlab绘制折线图基本操作

本篇博客主要总结matlab绘制折线图的基本操作,使用的函数是plot函数,关于plot的函数语法规则,这里不再赘述,可以参考matlab官方文档,https://ww2.mathworks.cn/help/matlab/ref/plot.html#d124e1037051,不看…

matlab 画折线图(美化)

常规的折线图我们可以调用plot()函数进行画图,并且我们可以修改参数画出不同颜色,各种样式的图,但是我们怎么样才能在折线图上加上数据标签,我们需要调用text()函数来完成,进行我们直接进入实战 首先我们先查看一下要…

Matlab中绘制折线图(附matlab代码)

Matlab中绘制折线图 一般来说,折线图更加直观、更加可视化。因此,本文给出一种使用MATLAB处理数据得到折线图的教程。 1、创建折线图 x1:1:5;%x轴上的数据,第一个值代表数据开始,第二个值代表间隔,第三个值代表终止…

Python 的Int的最大值是多少?

Python 的Int的最大值是多少? 非常大

C语言中INT数据类型的最小值和最大值

INT数据类型的最小值: -2,147,483,648,转化成二进制1000 0000 0000 0000 0000 0000 0000 0000 第一位1即时符号位,也是数值位,2312,147,483,648 INT数据类型的最大值 2,147,483,647,转化为二进制 0111 1111 1111 1…

java int 的最大值 Integer.MAX_VALUE 是 2147483647 / 二十一亿多的一个整数

java int 类整数的最大值是 2 的 31 次方 - 1 2147483648 - 1 2147483647 可以用 Integer.MAX_VALUE 表示它,即 int value Integer.MAX_VALUE; Integer.MAX_VALUE 1 Integer.MIN_VALUE -2147483648 再大的数就要用 long (最大值 2 的 63 次方 - …

算法| Java的int类型最大值为什么是21亿多?

开篇 本文主要介绍在Java中,为什么int类型的最大值为2147483647。 理论值 我们都知道在Java中,int 的长度为32位。 理论上,用二进制表示,32位每一位都是1的话,那么这个数是多少呢? 我们来计算一下&…

C++int型的数到底最大值是多少

int的范围是-2的31次方到2的31次方-1。 为什么是31次方呢:因为我的电脑是4个字节表示int,一个字节占8位。所以就32位,-1是因为int是signed有符号位的,所以就31。为什么正数要31-1呢:个人理解:(假设4个1,如…

2019latex安装教程

菜鸡一枚,一开始装latex找了好多博客,按照他们的步骤走还是失败,最后把他们集齐,拼在了一起,终于召唤出了latex!!! 参考博客链接: 安装教程 环境变量教程 安装教程 环境…

Latex安装教程 (TeX Live 和 TeXStudio)

文章目录 TeX Live 安装(1) 进入官网 [Tex Live](http://tug.org/texlive/)(2) 选择 on DVD(3) 选择 downloading the TeX Live ISO image and burning your own DVD(4) 选择 download from a nearby CTAN mirror(5) 选择 texlive2020.iso下载(6) 下载后解压:在解压…

latex安装教程(texlive+texstudio)并添加IEEE模板

[TOC]latex安装教程(texlivetexstudio)并添加IEEE模板 texlive安装 网址:https://tug.org/texlive/ texlive可以选择线上安装也可以选择线下安装(建议线上安装) texlive线上安装 第一步 第二步 第三步 点击 insta…

TeX Live2018_latex安装教程

YS 2018年8月5日15:00:32 点击链接https://tug.org/texlive/ 注:Latex不止TeX这一种,这里只给出了TeX的安装,如果想尝试别的软件的同学可以自行寻找其他教程。 并执行如下操作: 第一步 第二步 第三步 第四步 第五步 装载下载…

LateX安装下载使用详细教程

马上美赛了,想想很多队伍都会用Latex来进行论文排版,因为其功能真的十分强大,故在此发一篇安装下载的详细教程。一.关于 LaTeX和CTeX 1.LaTeX: LaTeX是一种基于ΤΕΧ的排版系统,由美国计算机学家莱斯利兰伯特&#xf…

Latex安装教程 —— textlive+textstudio+基础环境配置

一、下载textlive 下载地址:TeX Live - TeX Users Grouphttps://tug.org/texlive/ 步骤: 1.根据系统选择下载页面 2.运行下载安装程序 3.按照下载程序提示安装textlive 注意:textlive有一个选择镜像源的选项,可以选择国内的镜像…