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');
相关推荐
Wuliwuliii几秒前
贡献延迟计算DP
数据结构·c++·算法·动态规划·dp
七夜zippoe4 分钟前
异步编程实战:构建高性能Python网络应用
开发语言·python·websocket·asyncio·aiohttp
ysn111114 分钟前
简单多边形三角剖分---耳切法(含源码)
算法
tianyuanwo5 分钟前
Python虚拟环境深度解析:从virtualenv到virtualenvwrapper
开发语言·python·virtualenv
e疗AI产品之路5 分钟前
一文介绍Philips DXL心电图算法
算法·pan-tompkins·心电分析
看见繁华14 分钟前
GO 教程
开发语言·后端·golang
小袁顶风作案15 分钟前
leetcode力扣——135.分发糖果
算法·leetcode·职场和发展
Yy_Yyyyy_zz17 分钟前
深入理解 Go 的多返回值:语法、编译原理与工程实践
开发语言·后端·golang
AAA.建材批发刘哥19 分钟前
02--C++ 类和对象上篇
开发语言·c++