加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

matlab 曲线线型、颜色和标记点 和 legend

(2011-09-22 17:00:59)
标签:

matlab

曲线

legend

杂谈

分类: 学习资料收藏

 a=linspace(1,2,10)
 plot(a,'--pr','linewidth',1.5,'MarkerEdgeColor','r','MarkerFaceColor','m','MarkerSize',10)
 legend('a','Location','best')
 title('a','FontName','Times New Roman','FontWeight','Bold','FontSize',16)
 xlabel('T','FontName','Times New Roman','FontSize',14)
 ylabel('a','FontName','Times New Roman','FontSize',14,'Rotation',0)
 axis auto equal
 set(gca,'FontName','Times New Roman','FontSize',14)
 
1.曲线线型、颜色和标记点类型
 plot(X1,Y1,LineSpec, …) 通过字符串LineSpec指定曲线的线型、颜色及数据点的标记类型。
 
     线型      颜色     数据点标记类型
 标识符 意义 标识符 意义 标识符   意义
 
- 实线 r 红色 +   加号
 -. 点划线 g 绿色 o   圆圈
 -- 虚线 b 蓝色 *   星号
 : 点线 c 蓝绿色 .  
    m 洋红色 x   交叉符号
    y 黄色 square(或s) 方格
    k 黑色 diamond(或d) 菱形
    w 白色 ^   向上的三角形
       向下的三角形
       向左的三角形
       向右的三角形
      pentagram(或p) 五边形
      hexagram(或h) 六边形
 
2.设置曲线线宽、标记点大小,标记点边框颜色和标记点填充颜色等。
 plot(…,’Property Name’, Property Value, …)
 
Property Name 意义    选项
 LineWidth 线宽    数值,如0.5,1等,单位为points
 MarkerEdgeColor 标记点边框线条颜色 颜色字符,如’g’, ’b’等
 MarkerFaceColor 标记点内部区域填充颜色 颜色字符
 MarkerSize 标记点大小   数值,单位为points

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文件。后面一段是对应的翻译和说明
 
        'North'              inside plot box near top
 
        'South'              inside bottom
 
        'East'               inside right
 
        'West'               inside left
 
        'NorthEast'          inside top right (default)
 
        '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
 
        '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
 
        'North'             图例标识放在图顶端
 
        'South'            图例标识放在图底端
 
        'East'               图例标识放在图右方
 
        'West'              图例标识放在图左方
 
        'NorthEast'       图例标识放在图右上方(默认)
 
        'NorthWest      图例标识放在图左上方
 
        'SouthEast'      图例标识放在图右下角
 
        'SouthWest'     图例标识放在图左下角
 
(以上几个都是将图例标识放在框图内)
 
        'NorthOutside'          图例标识放在图框外侧上方
 
        'SouthOutside'         图例标识放在图框外侧下方
 
        'EastOutside'           图例标识放在图框外侧右方
 
        'WestOutside'          图例标识放在图框外侧左方
 
        'NorthEastOutside'   图例标识放在图框外侧右上方
 
        'NorthWestOutside' 图例标识放在图框外侧左上方
 
        'SouthEastOutside'   图例标识放在图框外侧右下方
 
        'SouthWestOutside' 图例标识放在图框外侧左下方
 
(以上几个将图例标识放在框图外)
 
        'Best'                      图标标识放在图框内不与图冲突的最佳位置
 
        'BestOutside'           图标标识放在图框外使用最小空间的最佳位置
 
还是用上面的例子
 
legend('sin','cos','location','northwest')可以将标识框放置在图的左上角。
 
    Examples:
 
        x = 0:.2:12;
 
        plot(x,bessel(1,x),x,bessel(2,x),x,bessel(3,x));
 
        legend('First','Second','Third');
 
        legend('First','Second','Third','Location','NorthEastOutside')
 
        b = bar(rand(10,5),'stacked'); colormap(summer); hold on
 
        x = plot(1:10,5*rand(10,1),'marker','square','markersize',12,...
 
                 'markeredgecolor','y','markerfacecolor',[.6 0 .6],...
 
                 'linestyle','-','color','r','linewidth',2); hold off
 
        legend([b,x],'Carrots','Peas','Peppers','Green Beans',...
 
                  'Cucumbers','Eggplant')

http://www.zdh1909.com/html/matlab/14642_3.html

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有