Matlab 图例 位置的不同命令
Matlab 图例 位置的不同命令
本文是转载的,我怕忘了,所以转载到我的页面来
原文:http://blog.sina.com.cn/s/blog_7db803c10102weyk.html
转载1:
https://www.cnblogs.com/xym4869/p/12243271.html
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)');
然而,我们却可以通过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位置选择
一个简单的表格是这么创建的:
设置 | 位置 |
---|---|
‘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')
如果只想显示第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')
还可以使用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')
不显示方框:
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','Box','off')
Matlab 图例 位置的不同命令相关推荐
- matlab 图中的legend,matlab中legend加图示命令的使用
matlab中legend什么意思 matlab中的legend是图例的意思. legend()使用格式:legend(string1,string2,string3, ...,n) string1- ...
- matlab 返回变量类型的命令,MATLAB主要命令汇总
MATLAB主要命令汇总 1.常用信息 ·help:在线帮助(显示在命令窗). ·helpwin:在线帮助(独立窗口显示). ·ver:MATLAB及工具箱的版本信息. 2.管理工作区命令 ·who: ...
- [初学笔记]matlab的具体类型图形命令函, bar条形图
转自 http://www.cnblogs.com/vanker/p/4245315.html matlab help document 1 二维图形的函数命令 bar 长条图 scatter 散点图 ...
- R语言ggplot2可视化:自定义设置连续变量图例(legend)宽度(width)、自定义设置连续变量图例位置(position)、自定义设置连续变量图例连续渐变
R语言ggplot2可视化:自定义设置连续变量图例(legend)宽度(width).自定义设置连续变量图例位置(position).自定义设置连续变量图例连续渐变 #初始示例(图例互相分离.图例细线 ...
- R语言使用ggplot2包使用geom_boxplot函数绘制基础分组箱图(设置图例位置、移除图例)实战
R语言使用ggplot2包使用geom_boxplot函数绘制基础分组箱图(设置图例位置.移除图例)实战 目录 R语言使用ggplot2包使用geom_boxplot函数绘制基础分组箱图(设置图例位置 ...
- R语言使用ggplot2包使用geom_violin函数绘制分组小提琴图(配置图例位置、移除图例)实战
R语言使用ggplot2包使用geom_violin函数绘制分组小提琴图(配置图例位置.移除图例)实战 目录
- R语言使用ggplot2包使用geom_dotplot函数绘制分组点图(改变图例位置)实战(dot plot)
R语言使用ggplot2包使用geom_dotplot函数绘制分组点图(改变图例位置)实战(dot plot) 目录 R语言使用ggplot2包使用geom_dotplot函数绘制分组点图(改变图例位 ...
- R语言使用ggplot2包geom_jitter()函数绘制分组(strip plot,一维散点图)带状图(改变图例位置、移除图例)实战
R语言使用ggplot2包geom_jitter()函数绘制分组(strip plot,一维散点图)带状图(改变图例位置.移除图例)实战 目录 R语言使用ggplot2包geom_jitter()函数 ...
- R语言使用ggplot2包使用geom_density()函数绘制分组密度图(改变图例位置、移除图例)实战(density plot)
R语言使用ggplot2包使用geom_density()函数绘制分组密度图(改变图例位置.移除图例)实战(density plot) 目录 R语言使用ggplot2包使用geom_density() ...
- python图例位置_Python | 图例位置
python图例位置 Legends are one of the key components of data visualization and plotting. Matplotlib can ...
最新文章
- 计算机山西特岗考试题库,山西特岗历年试题
- 2!=5 or 0在python中是否正确-Python 中的 or and 运算,看这一篇就够
- golang并发和并行
- 高等数学上-赵立军-北京大学出版社-题解-练习5.3
- access订单明细表怎么做_图书销售订单明细表 (4)
- 第一款Micropython图形化编辑器—Python Editor
- JavaScript自动提示1.1
- 利润从而何来?​
- 在CRM中怎么应用大数据挖掘
- python车牌识别系统开源代码_python实现车牌识别的示例代码
- 三转CHM文件故障解决
- 通过Downward API传递pod元数据
- 博客迁移到sunface.io
- 求1-100之间的和
- Intellij IDEA优化配置(1)------Darcula主题的选择以及字体和颜色配置(基于Intellij IDEA 2019.1)
- 尚硅谷和黑马java,全网首发!
- JS输出26个英文大小写字母
- 一道笔试题(求质数乘积)
- 【Pytorch】常用函数功能介绍和注意事项
- (47)【漏洞发现】漏扫工具合集、WAF绕过分类