- 折线图
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');

- 柱状图
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');
