matlab常见的配图代码实现1

  1. 折线图
Matlab 复制代码
x = linspace(0, 10, 100);
y1 = sin(x);y2 = cos(x);
figure;
plot(x, y1, '-o', 'LineWidth', 2, 'MarkerSize', 6, 'MarkerFaceColor', 'b');
hold on;plot(x, y2, '-s', 'LineWidth', 2, 'MarkerSize', 6, 'MarkerFaceColor', 'r');
title('折线图');
xlabel('X轴');
ylabel('Y轴');
legend('sin(x)', 'cos(x)');
grid on;
saveas(gcf, '折线图.jpg');

2.散点图

Matlab 复制代码
x = randn(100, 1);
y = randn(100, 1);
colors = rand(100, 1);
sizes = 100 * rand(100, 1);
figure;scatter(x, y, sizes, colors, 'filled');title('散点图');
xlabel('X轴');
ylabel('Y轴');
colorbar;
grid on;
saveas(gcf, '散点图.jpg');
  1. 柱状图
Matlab 复制代码
categories = categorical({'A', 'B', 'C', 'D'});
values1 = [5, 7, 8, 6];
values2 = [3, 4, 5, 2];
figure;
bar(categories, [values1', values2'], 'stacked');title('柱状图');
xlabel('类别');
ylabel('数值');
legend('组1', '组2');
grid on;
saveas(gcf, '柱状图.jpg');
相关推荐
不吃香菜学java3 小时前
Redis的java客户端
java·开发语言·spring boot·redis·缓存
贵沫末3 小时前
python——打包自己的库并安装
开发语言·windows·python
文祐4 小时前
C++类之虚函数表及其内存布局(一个子类继承一个父类)
开发语言·c++
白羊by4 小时前
YOLOv1~v11 全版本核心演进总览
深度学习·算法·yolo
zuowei28894 小时前
华为网络设备配置文件备份与恢复(上传、下载、导出,导入)
开发语言·华为·php
xiaohe074 小时前
超详细 Python 爬虫指南
开发语言·爬虫·python
嗑嗑嗑瓜子的猫5 小时前
Java!它值得!
java·开发语言
xiaoshuaishuai85 小时前
C# GPU算力与管理
开发语言·windows·c#
lsx2024065 小时前
SVN 创建版本库
开发语言
xiaotao1315 小时前
01-编程基础与数学基石:Python错误与异常处理
开发语言·人工智能·python