MATLAB基础--plot出数据时figure设置

1、前记:上接MATLAB基础--数据出图中的内容介绍figure出数据图时一些细致的设置。

      主要包括线型设置,坐标区设置,legend设置

function[]=plot_en()
disp('------------------------------------------------------------------');
disp('Plots the Energy balance');

load envar.dat;
load timevar.dat;

EN=envar;T=timevar;

set(0,'DefaultLineLineWidth',1.5)%默认线条粗细

fh1=figure('Name','Energy Balance','NumberTitle','off');%取消figur图编号
subplot(2,1,1)%窗口划分为两行一列,第一个

set(fh1, 'color', 'white'); % figur背景设为白色
plot(T,EN(:,1),'-r',T,EN(:,4),'-.m');%plot数据

set (gca,'fontsize',10,'fontweight','n','fontname','times new romans','linewidth',0.5,'Box', 'off','TickDir','out' );
%               刻度字体大小                                 刻度线条粗细
%               图框闭合成Box-on,off 不闭合                  刻度线向里-in,out向外
%title(' ENERGY BALANCE OF SIMULATION THROUGH LSIM ','FontSize',8);  %标题名

xlabel('time (s)','FontSize',10);   %X轴单位,字体大小
ylabel('Energy (J)','FontSize',10); %Y轴单位,字体大小

h=legend('Potential','Total');      %线型标识名
set(h,'Orientation','horizontal','Color', 'c','Box', 'on','Location','best','fontsize',10,'fontweight','n','fontname','times new romans','linewidth',2.5)
%    对线型标识名legend的设置---蓝绿色C背景box包围打开-on,关闭-off ;位置自动最佳;legend字体大小10;box线框粗细2.5 
% plot常用颜色,r 红,g 绿,b 蓝,c 蓝绿,m 紫红,y 黄,k 黑,w 白;color阈值[1 0 0]--代表红色
subplot(2,1,2)%%窗口划分为两行一列,第2个
set(fh1, 'color', 'white'); % sets the color to white 
plot(T,EN(:,2),T,EN(:,3));
set (gca,'fontsize',10,'fontweight','n','fontname','times new romans','linewidth',0.5,'Box', 'on','TickDir','in' );
% title(' ENERGY BALANCE OF SIMULATION THROUGH LSIM ','FontSize',8);
xlabel('time (s)','FontSize',10);
ylabel('Energy (J)','FontSize',10);
h=legend('Kinetic','Actuator');
set(h,'Orientation','horizontal','Color', 'none','Box', 'off','Location','best','fontsize',10,'fontweight','n','fontname','times new romans','linewidth',0.5)
% legend位置northoutside,外-北;'north' | 'south' | 'east' | 'west' |'northeast' | 'northwest' | 'southeast' | 'southwest' | 'northoutside' |
%'bestoutside'|'northeast' | 'northwest' | 'southeast' | 'southwest' | 'northeastoutside' |
%'northwestoutside' | 'southeastoutside' | 'southwestoutside'

结果显示:

                                          

2、figure数据出图时,通过导出设置或插入功能也可以丰富,如在figure中添加方框、坐标区、添加注释等。如下简单操作以示....

                                              

3、有时候想查看某一个插入功能的代码时,可以右键选中后点击显示代码,在有时候可以更加生成的代码重构数据出图的代码。

                                         

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JianRobSim

嘤嘤其名,求其友声!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值