声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

声振论坛 展示 科学计算 matlab 查看内容

matlab中legend的用法

2016-5-10 09:06| 发布者: Edinburgh| 查看: 1170| 评论: 0|原作者: 不详|来自: 新浪自白人的博客

摘要: 用Matlab画图时,有时候需要对各种图标进行标注,例如,用“+”代表A的运动情况,“*”代表B的运动情况。legend函数的基本用法是LEGEND(string1,string2,string3, ...)分别将字符串1、字符串2、字符串3……标注到图 ...

用Matlab画图时,有时候需要对各种图标进行标注,例如,用“+”代表A的运动情况,“*”代表B的运动情况。

legend函数的基本用法是

LEGEND(string1,string2,string3, ...)

分别将字符串1、字符串2、字符串3……标注到图中,每个字符串对应的图标为画图时的图标。

例如:

plot(x,sin(x),'.b',x,cos(x),'+r')

legend('sin','cos')这样可以把"."标识为'sin',把"+"标识为"cos"

还可以用LEGEND(...,'Location',LOC) 来指定图例标识框的位置

这些是Matlab help文件。后面一段是对应的翻译和说明

  1.   'North'              inside plot box near top
  2.         'South'              inside bottom
  3.         'East'               inside right
  4.         'West'               inside left
  5.         'NorthEast'          inside top right (default)
  6.         'NorthWest           inside top left
  7.         'SouthEast'          inside bottom right
  8.         'SouthWest'          inside bottom left
  9.         'NorthOutside'       outside plot box near top
  10.         'SouthOutside'       outside bottom
  11.         'EastOutside'        outside right
  12.         'WestOutside'        outside left
  13.         'NorthEastOutside'   outside top right
  14.         'NorthWestOutside'   outside top left
  15.         'SouthEastOutside'   outside bottom right
  16.         'SouthWestOutside'   outside bottom left
  17.         'Best'               least conflict with data in plot
  18.         'BestOutside'        least unused space outside plot

  19.         'North'             图例标识放在图顶端
  20.         'South'            图例标识放在图底端
  21.         'East'               图例标识放在图右方
  22.         'West'              图例标识放在图左方
  23.         'NorthEast'       图例标识放在图右上方(默认)
  24.         'NorthWest      图例标识放在图左上方
  25.         'SouthEast'      图例标识放在图右下角
  26.         'SouthWest'     图例标识放在图左下角
  27. (以上几个都是将图例标识放在框图内)
  28.         'NorthOutside'          图例标识放在图框外侧上方
  29.         'SouthOutside'         图例标识放在图框外侧下方
  30.         'EastOutside'           图例标识放在图框外侧右方
  31.         'WestOutside'          图例标识放在图框外侧左方
  32.         'NorthEastOutside'   图例标识放在图框外侧右上方
  33.         'NorthWestOutside' 图例标识放在图框外侧左上方
  34.         'SouthEastOutside'   图例标识放在图框外侧右下方
  35.         'SouthWestOutside' 图例标识放在图框外侧左下方
  36. (以上几个将图例标识放在框图外)
  37.         'Best'                      图标标识放在图框内不与图冲突的最佳位置
  38.         'BestOutside'           图标标识放在图框外使用最小空间的最佳位置
  39. 还是用上面的例子
  40. legend('sin','cos','location','northwest')可以将标识框放置在图的左上角。
复制代码


最新评论

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-4-24 01:04 , Processed in 0.048652 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部