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');
相关推荐
福大大架构师每日一题14 小时前
2026-01-15:下一个特殊回文数。用go语言,给定一个整数 n,求出一个比 n 更大的最小整数,该整数需要满足两条规则: 1. 它的十进制表示从左到右与从右到左完全一致(即读起来是对称的)。 2
python·算法·golang
Aerkui14 小时前
Go 泛型(Generics)详解
开发语言·后端·golang
clive.li14 小时前
go-webmvc框架推荐
开发语言·后端·golang
努力进修14 小时前
算法刷题无边界!Hello-Algo+cpolar 随时随地想学就学
算法·cpolar
寻寻觅觅☆14 小时前
东华OJ-基础题-127-我素故我在(C++)
开发语言·c++·算法
ab15151714 小时前
2.13完成101、102、89
开发语言·c++·算法
切糕师学AI14 小时前
NFS(网络文件系统)详解
开发语言·网络·php
芝士爱知识a15 小时前
[2026深度测评] AI期权交易平台推荐榜单:AlphaGBM领跑,量化交易的新范式
开发语言·数据结构·人工智能·python·alphagbm·ai期权工具
overmind15 小时前
oeasy Python 113 内置函数sorted中使用 reverse和key
开发语言·python
黎潇lulu15 小时前
Java运算符基础知识
java·开发语言