绘图功能及其设置

绘制一个点

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);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值