MATLAB绘图入门庖丁解牛 - 图例位置和风格修改

Posted by lowkeng on Saturday, February 11, 2023

设置图例位置

默认位置是NorthEast 除了可以更改图例东西南北(图框的上下左右侧)位置,还可以设置图例显示在图片之外

clc
clear 
close all
Npoint = 101;
x = linspace(0,10,Npoint);
y1 = besselj(1,x);
y2 = besselj(2,x);
y3 = besselj(3,x);
y4 = besselj(4,x);
y5 = besselj(5,x);
H = plot(x,y1,x,y2,x,y3,x,y4,x,y5);
legend('First','Second','Third','Fourth','Fifth','Location','NorthEastOutside')

image-20230210145355771

横向排列图例

%Matlab中legend的横排,注意,Location位置改变为North

clc
clear 
close all
Npoint = 101;
x = linspace(0,10,Npoint);
y1 = besselj(1,x);
y2 = besselj(2,x);
y3 = besselj(3,x);
y4 = besselj(4,x);
y5 = besselj(5,x);
H = plot(x,y1,x,y2,x,y3,x,y4,x,y5);
h1 = legend(H([1 3 5]),'First','Third','Fifthth','Location','North');
set(h1,'Orientation','horizon')
% set(h1,'Orientation','horizon','Box','off');%不显示图例方框

image-20230210145515282

image-20230210145612690

「真诚赞赏,手留余香」

Self-Disciplined and Motivated

真诚赞赏,手留余香

使用微信扫描二维码完成支付


comments powered by Disqus