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');
相关推荐
电子连接器CAE与高频分析2 小时前
Matlab添加标题title与标签lable
开发语言·matlab
努力弹琴的大风天3 小时前
MATLAB遇到内部问题,需要关闭,Crash Decoding : Disabled - No sandbox or build area path
开发语言·matlab
槐月杰3 小时前
C语言中冒泡排序和快速排序的区别
c语言·算法·排序算法
奋进的小暄4 小时前
数据结构(java)栈与队列
java·开发语言·数据结构
笺上山河梦4 小时前
文件操作(二进制文件)
开发语言·c++·学习·算法
大慕慕好懒5 小时前
PHP弱类型hash比较缺陷
算法·哈希算法
snowfoootball6 小时前
最短路问题
数据结构·算法
有杨既安然6 小时前
Python自动化办公
开发语言·人工智能·深度学习·机器学习
有你的冬天1987 小时前
数据结构(一)
数据结构·算法
满怀10157 小时前
【Python进阶】列表:全面解析与实战指南
python·算法