subplot上标记、画图


用subplot画图后,如何在每个子图下方添加标题,直接用title,则显示的内容是在默认的图形上方,而不是在图形的下方。若要求在每个图形下方加标题,如一幅图中用subplot画了3个子图,如何在每个子图下方加标题,  该怎么实现呢?

可用xlabel。
x=linspace(0,2*pi,30); y=sin(x); z=cos(x);
u=2*sin(x).*cos(x); v=sin(x)./cos(x);
subplot(2,2,1),plot(x,y),axis([0 2*pi -1 1]),xlabel('sin(x)')
subplot(2,2,2),plot(x,z),axis([0 2*pi -1 1]), xlabel ('cos(x)')
subplot(2,2,3),plot(x,u),axis([0 2*pi -1 1]), xlabel ('2sin(x)cos(x)')
subplot(2,2,4),plot(x,v),axis([0 2*pi -20 20]), xlabel ('sin(x)/cos(x)')



title('position',[x,y]),x,y为你想加入的坐标,改变标题的位置。

% time sequence
clear all; clc; close all;

t = 0:0.01:7;
% plot
subplot(4,1,1);
cla; hold on; box on;
plot(t, sin(t), 'r');
grid on;
subplot(4,1,2);
cla; hold on; box on;
plot(t, cos(t), 'r');
grid on;
subplot(4,1,3);
cla; hold on; box on
plot(t, 2*sin(t), 'r');
grid on;
subplot(4,1,4);
cla; hold on; box on
plot(t, 2*cos(t), 'r');
grid on;
% save figure
message = sprintf('Now, save the figure.');
uiwait(msgbox(message));
saveas(gcf,'1.fig');
% close figure
message = sprintf('Close the figure.');
uiwait(msgbox(message));
close all;
% open figure
message = sprintf('Open the figure.');
uiwait(msgbox(message));
open 1.fig
hold all;
sublist = get(gcf, 'children');
% re-plot
message = sprintf('Plot the figure without erasering the old plot.');
uiwait(msgbox(message));
hold on;
plot(sublist(4), t, cos(t), 'g');
hold on;
plot(sublist(3), t, sin(t), 'g');
hold on;
plot(sublist(2), t, 2*cos(t), 'g');
hold on;
plot(sublist(1), t, 2*sin(t), 'g');


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值