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');
相关推荐
0 0 04 小时前
CCF-CSP 39-2 水印检查(watermark)【C++】
c++·算法
plus4s5 小时前
2月15日(78,80,81题)
c++·算法·图论
能源系统预测和优化研究5 小时前
【原创改进代码】考虑碳交易与电网交互波动惩罚的共享储能电站优化配置与调度模型
算法·能源
935965 小时前
机考27 翻译21 单词14
c语言·数据结构·算法
光泽雨5 小时前
C# 中 Assembly 类详解
开发语言·c#
少控科技5 小时前
C#基础训练营 - 02 - 运算器
开发语言·c#
Riemann~~6 小时前
C语言嵌入式风格
c语言·开发语言
回敲代码的猴子7 小时前
2月14日打卡
算法
blackicexs7 小时前
第四周第七天
算法
期末考复习中,蓝桥杯都没时间学了8 小时前
力扣刷题19
算法·leetcode·职场和发展