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');
相关推荐
转角羊儿几秒前
精灵图案例
开发语言·前端·javascript
像素猎人2 分钟前
数组中的二分查找函数:lower_bound【第一个 >= 目标值的元素的值或者下标】 和 upper_bound【第一个 > 目标值的元素的值或者下标】
数据结构·算法
l1t4 分钟前
Qwen 3.5plus编写的求解欧拉计划901题python程序优化
开发语言·python
T0uken8 分钟前
【Python】docxnote:优雅的 Word 批注
开发语言·python·word
9稳9 分钟前
基于智能巡检机器人与PLC系统联动控制设计
开发语言·网络·数据库·嵌入式硬件·plc
crediks10 分钟前
MTGR(美团生成式推荐框架)总结文档
人工智能·深度学习·算法
im_AMBER10 分钟前
Leetcode 143 搜索插入位置 | 搜索二维矩阵
数据结构·算法·leetcode
承渊政道11 分钟前
C++学习之旅【IO库相关内容介绍】
c语言·开发语言·c++·学习·macos·visual studio
小年糕是糕手12 分钟前
【35天从0开始备战蓝桥杯 -- Day5】
数据结构·数据库·c++·算法·蓝桥杯
Ronin30513 分钟前
【Qt窗口】Qt窗口
开发语言·qt·qt窗口