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');
相关推荐
郝亚军7 分钟前
FE1.1S-BQFN24BT可以指定IP端口吗?
开发语言·php
阿里嘎多学长10 分钟前
2026-08-04 GitHub 热点项目精选
开发语言·程序员·github·代码托管
晴天1624 分钟前
Rust 快速入门 (从 JavaScript 开发者视角)-Day09
开发语言·javascript·rust
一次旅行38 分钟前
RLHF全链路深度解析:Reward Model数学推导+PPO完整实战,对比GRPO轻量化方案
人工智能·算法·机器学习
Wang's Blog40 分钟前
AI Agent白手起家29: Few Shot 提示词工程实战
人工智能·算法
步行cgn1 小时前
carList.forEach(System.out::println)
java·开发语言·mybatis
进击的程序猿~1 小时前
Go 内存分配与垃圾回收源码深度学习手册
开发语言·后端·golang
June`1 小时前
warp shuffle指令
c++·人工智能·算法·cuda
geovindu1 小时前
go:Bit Operation Algorithm
开发语言·后端·算法·golang·位运算法