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');
相关推荐
卡洛斯(编程版9 分钟前
(1) 哈希表全思路-20天刷完Leetcode Hot 100计划
python·算法·leetcode
疯狂的代M夫10 分钟前
C++对象的内存布局
开发语言·c++
mit6.82435 分钟前
Linux下C#项目构建
开发语言·c#
群联云防护小杜39 分钟前
从一次 DDoS 的“死亡回放”看现代攻击链的进化
开发语言·python·linq
霸敛1 小时前
好家园房产中介网后台管理完整(python+flask+mysql)
开发语言·python·flask
NAGNIP1 小时前
DeepSeekMoE 架构解析
算法
Momentary_SixthSense1 小时前
RESP协议
java·开发语言·javascript·redis·后端·python·mysql
不喜欢学数学er1 小时前
算法第五十二天:图论part03(第十一章)
算法·深度优先·图论
养成系小王1 小时前
四大常用排序算法
数据结构·算法·排序算法
NAGNIP1 小时前
一文搞懂DeepSeek LLM
算法