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');
相关推荐
军军君0112 小时前
Three.js基础功能学习五:雾与渲染目标
开发语言·前端·javascript·学习·3d·前端框架·three
charlie11451419113 小时前
FreeRTOS:软件定时器(Software Timers)与时间管理
开发语言·笔记·学习·freertos·实时操作系统·工程
2401_8414956413 小时前
【LeetCode刷题】寻找重复数
数据结构·python·算法·leetcode·链表·数组·重复数
washingtin13 小时前
Get “https://registry-1.docker.io/v2/“: context deadline exceeded
java·开发语言
only-lucky13 小时前
Python版本OpenCV
开发语言·python·opencv
罗技12313 小时前
Easysearch 集群监控实战(下):线程池、索引、查询、段合并性能指标详解
前端·javascript·算法
三万棵雪松13 小时前
【python-基础】
开发语言·python
一路往蓝-Anbo13 小时前
C语言从句柄到对象 (七) —— 给对象加把锁:RTOS 环境下的并发安全
java·c语言·开发语言·stm32·单片机·嵌入式硬件·算法
先做个垃圾出来………13 小时前
2610.转换二维数组
开发语言·python
中國龍在廣州13 小时前
谈谈2025年人工智能现状及发展趋势分析
人工智能·深度学习·算法·自然语言处理·chatgpt·机器人·机器人学习