Matlab中legend默认的位置在NorthEast,如图所示​
%Matlab中legend的位置设置
clc
clear
close all
Npoint = 100;
x = linspace(0,4*pi,Npoint);
y1 = sin(x);
y2 = cos(x);
H = plot(x,y1,x,y2);
legend(‘sin(x)’,‘cos(x)’);
Matlab中legend的位置

然而,我们却可以通过Location对legend的位置进行改变,变为North,如图所示
%Matlab中legend的位置设置
clc
clear
close all
Npoint = 100;
x = linspace(0,4*pi,Npoint);
y1 = sin(x);
y2 = cos(x);
H = plot(x,y1,x,y2);
legend(‘sin(x)’,‘cos(x)’,‘Location’,‘North’);
Matlab中legend的位置
Matlab中有许多位置可以选择:
‘North’ inside plot box near top
‘South’ inside bottom
‘East’ inside right
‘West’ inside left
‘NorthEast’ inside top right (default for 2-D plots)
‘NorthWest’ inside top left
‘SouthEast’ inside bottom right
‘SouthWest’ inside bottom left
‘NorthOutside’ outside plot box near top
‘SouthOutside’ outside bottom
‘EastOutside’ outside right
‘WestOutside’ outside left
‘NorthEastOutside’ outside top right (default for 3-D plots)
‘NorthWestOutside’ outside top left
‘SouthEastOutside’ outside bottom right
‘SouthWestOutside’ outside bottom left
‘Best’ least conflict with data in plot 与绘图中的数据冲突最小
‘BestOutside’ least unused space outside plot
Matlab中还可以选择某条曲线legend的指定显示
%Matlab中legend的选择
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’)
Matlab中legend的位置
如果只想显示第1、3、5条,也很简单
%Matlab中legend的选择
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’,‘NorthEastOutside’)
Matlab中legend的位置
此外,还可以使用Orientation对legend进行横向排列
%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’)
Matlab中legend的位置

Matlab中legend的位置
参考:
http://www.360doc.com/content/14/0722/17/13670635_396317423.shtml
http://blog.sina.com.cn/s/blog_7db803c10102weyk.html

matlab画图 legend的位置相关推荐

  1. Matlab中legend的位置

    Matlab中legend默认的位置在NorthEast,如图所示​ %Matlab中legend的位置设置 clc clear close all Npoint = 100; x = linspac ...

  2. matlab调整legend大小,【MATLAB】调整legend的大小位置

    源地址: MATLAB中plot命令绘图微调的几个注记 1.MATLAB如何从硬盘读取文件. 2.如何微调subplot子图的位置. 3.plot命令绘曲线时,曲线上的标志如何调整大小. 4.坐标轴的 ...

  3. matlab调整legend大小,[转载]【matlab】MATLAB中调整legend的大小位置

    1.MATLAB如何从硬盘读取文件. 2.如何微调subplot子图的位置. 3.plot命令绘曲线时,曲线上的标志如何调整大小. 4.坐标轴的调整. 6.坐标标题中如何标上标. 7.如何调整图示(l ...

  4. Matlab画图-非常具体,非常全面

    Matlab画图 强大的画图功能是Matlab的特点之中的一个,Matlab提供了一系列的画图函数,用户不须要过多的考虑画图的细节,仅仅须要给出一些基本參数就能得到所需图形,这类函数称为高层画图函数. ...

  5. Matlab设置Legend横排、分块

    高级用法1:指定legend显示的位置: legend({'str1','str2','strn'},'Location','SouthEast'); 比较鸡肋,画好图后树手动拖动就好了 高级用法2: ...

  6. matlab画图入门篇--各种基本图形绘制的函数与实例【转载】

    MATLAB画图入门篇--各种基本图形绘制的函数与实例 一. 二维图形(Two dimensional plotting) 1. 基本绘图函数(Basic plotting function):Plo ...

  7. 用matlab画图的好处,用matlab画图注意事项

    问题 开始用matlab画图时,使用默认设置,画出来的图不好看 比如,这段代码 x=0:0.1:10; y1=sin(x); y2=sin(x+3); plot(x,y1,x,y2) xlabel(' ...

  8. matlab画图时特殊符号的输入

    matlab画图时特殊符号的输入 (2018-03-08 16:00:43) 转自http://blog.sina.com.cn/s/blog_a7c0455c0102yaa6.html 1.在MAT ...

  9. matlab调节字体的函数,matlab 画图添加图例时,改变图例中字体大小

    matlab 画图时,在图形中添加图例要用到 legend 函数.还有一些图例属性可以调整,例如改变图例位置用到 'Location':改变图例中文字大小需要用到 'Fontsize'. 一般情况下, ...

最新文章

  1. 半导体与智能汽车行业解决方案
  2. 【c语言】蓝桥杯算法训练 4-2找公倍数
  3. 进程process与线程thread
  4. matlba 正交基
  5. 如何用python画圆形的代码-Python实现的圆形绘制(画圆)示例
  6. 一张图看懂数据库十年大格局!
  7. $\mathfrak {reputation}$
  8. vuecli打包后的dist目录无法访问_听说很多人都不会打包,教你Python实现前端自动化打包部署!...
  9. bba70_BBA的完整形式是什么?
  10. docunment对象
  11. Script:收集数据库中用户的角色和表空间等信息
  12. (转)不要跟赌场说谎,它真的比你老婆还了解你
  13. [2018.04.29 T3] 矩阵
  14. 神兵利器——敏感文件发现工具
  15. left join一对多只保留一条结果的解决方法
  16. paddlepaddle 人脸识别爬坑指南
  17. oracle中ln函数,PLSQL LN用法及代码示例
  18. bison版本问题导致编译报错:‘parse.error‘ is not used
  19. MVC4 jquery 样式 主题 用法(案例)
  20. PPT的那些事儿(趣资源)

热门文章

  1. 如何提高代码能力:程序员的成长之路(下)
  2. 弘辽科技:淘宝中秋过后还有什么活动?活动怎么策划好?
  3. Python debug 模块之pdb--(一)
  4. Windows10将于12月13日停止服务
  5. godaddy服务器做网站,godaddy虚拟主机怎么使用
  6. Quartus图文入门教程
  7. 软件测试面试怎样介绍自己的项目?会问到什么程度?
  8. 用PHP开发手机 APP应用API接口开发
  9. 解决添加打印机时出现错误两则:
  10. 头条号如何快速涨100W+粉丝?