绘制一个点
clear;clc;close all;
%%画出一个点
x = 11;
y = 48;
axis([9 12 35 45]);%确定x y轴的范围
plot(x,y,'*r');
xlabel('Time');
ylabel('Temperature')
title('Time and Temperature');
绘制线
clear;clc;close all;
x = 1:5;
y = randi([-10 10],[5 1]);
axis([1 5 -10 10]);%确定x y轴的范围
plot(x,y);
输出格式设置
'LineStyle' - 线型
'LineWidth' - 线条宽度
默认宽度为0.5
'Marker' - 标记符号
'MarkerIndices' - 要显示标记的数据点的索引
默认为全部,可以认为设置只显示其中部分点
'MarkerEdgeColor' - 标记轮廓颜色
'MarkerFaceColor' - 标记填充颜色
'MarkerSize' - 标记大小
标记大小默认为6
颜色
figure;subplot;legend;grid;
clear;clc;close all;
x = 1:5;
%%第一个画布
figure(1);
%%第一个小图
subplot(211);
hold on;
axis([1 5 0 5]);
y = [1 1 1 1 1];
y1 = [2 2 2 2 2];
plot(x,y);
plot(x,y1);
grid on;%网格
legend('Line1','Line2');%必须放在plot后面
%%第二个小图
subplot(212);
hold on;
y2 = [3 3 3 3 3];
y3 = [4 4 4 4 4];
plot(x,y2);
plot(x,y3);
%%第二个画布
figure(2);
%%第一个小图
subplot(211);
hold on;
axis([1 5 0 5]);
y = [1 1 1 1 1];
y1 = [2 2 2 2 2];
plot(x,y);
plot(x,y1);
%%第二个小图
subplot(212);
hold on;
y2 = [3 3 3 3 3];
y3 = [4 4 4 4 4];
plot(x,y2);
plot(x,y3);
子图
clear;clc;close all;
subplot(221);
subplot(223);
subplot(122)
柱状图
clear;clc;close all;
x = 1:5;
y = randi([1 10],[1 5]);
bar(x,y);