1、用 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 文件。后面一段是对应的翻译和说明No
2、rth inside plot box near topSouth inside bottomEast inside rightWest inside leftNorthEast inside top right (default)NorthWest inside top leftSouthEast inside bottom rightSouthWest inside bottom leftNorthOutside outside plot box near topSouthOutside outside bottomEastOutside outside rightWestOutside
3、outside leftNorthEastOutside outside top rightNorthWestOutside outside top leftSouthEastOutside outside bottom rightSouthWestOutside outside bottom leftBest least conflict with data in plotBestOutside least unused space outside plotNorth 图例标识放在图顶端South 图例标识放在图底端East 图例标识放在图右方West 图例标识放在图左方NorthEast
4、图例标识放在图右上方(默认)NorthWest 图例标识放在图左上方SouthEast 图例标识放在图右下角SouthWest 图例标识放在图左下角(以上几个都是将图例标识放在框图内)NorthOutside 图例标识放在图框外侧上方SouthOutside 图例标识放在图框外侧下方EastOutside 图例标识放在图框外侧右方WestOutside 图例标识放在图框外侧左方NorthEastOutside 图例标识放在图框外侧右上方NorthWestOutside 图例标识放在图框外侧左上方SouthEastOutside 图例标识放在图框外侧右下方SouthWestOutside 图例标识放在图框外侧左下方(以上几个将图例标识放在框图外)Best 图标标识放在图框内不与图冲突的最佳位置BestOutside 图标标识放在图框外使用最小空间的最佳位置还是用上面的例子legend(sin,cos,location,northwest)可以将标识框放置在图的左上角。