matlab plot函数说明和legend函数的基本用法(转)
2011-02-27 16:51
531 查看
plot函数可以接一些参数,来改变所画图像的属性(颜色,图像元素等)。下面是一些属性的说明
b blue(蓝色) . point(点) - solid(实线)
g green(绿色) o circle(圆圈) : dotted(点线)
r red(红色) x x-mark(叉号) -. dashdot (点画线)
c cyan(墨绿色) + plus(加号) -- dashed(虚线)
m magenta(紫红色) * star(星号) (none) no line
y yellow(***) s square(正方形)
k black(黑色) d diamond(菱形)
v triangle (down)
^ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram
Example
x = -pi:pi/10:pi;
y = tan(sin(x)) - sin(tan(x));
plot(x,y,'--rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',10)
· 用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文件。后面一段是对应的翻译和说明
'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')
b blue(蓝色) . point(点) - solid(实线)
g green(绿色) o circle(圆圈) : dotted(点线)
r red(红色) x x-mark(叉号) -. dashdot (点画线)
c cyan(墨绿色) + plus(加号) -- dashed(虚线)
m magenta(紫红色) * star(星号) (none) no line
y yellow(***) s square(正方形)
k black(黑色) d diamond(菱形)
v triangle (down)
^ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram
Example
x = -pi:pi/10:pi;
y = tan(sin(x)) - sin(tan(x));
plot(x,y,'--rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',10)
· 用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文件。后面一段是对应的翻译和说明
'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')
相关文章推荐
- matplotlib的legend函数解释说明
- Matlab中plot基本用法
- Matlab中plot函数及legend函数详解
- matlab图片,矩阵,函数的基本用法
- matlab画图基本函数和参数之plot
- Matlab中plot基本用法
- 【Matlab】Matlab中的plot函数及legend函数解析 持续更新...
- matlab画图基本函数和参数之plot
- 总结整理Matlab的plot函数用法
- MATLAB 基本小函数用法
- Matlab中plot基本用法
- matlab中PLOT指令的基本用法
- plot函数用法(MATLAB)
- 总结整理Matlab的plot函数用法
- matlab中plot()函数用法大全
- Matlab中画图函数汇总:plot/set/legend
- matlab画图函数用法,subplot,plot
- matplotlib的基本用法(四)——设置legend图例
- MATLAB中legend函数的用法
- MATLAB画图函数plot简单用法