转自:http://blog.sina.com.cn/s/blog_4a4927c70100klbw.html
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 蓝绿色 .
2.设置曲线线宽、标记点大小,标记点边框颜色和标记点填充颜色等。
plot(…,’Property Name’, Property Value, …)
Property Name 意义
LineWidth 线宽
MarkerEdgeColor 标记点边框线条颜色 颜色字符,如’g’, ’b’等
MarkerFaceColor 标记点内部区域填充颜色 颜色字符
MarkerSize 标记点大小
3.坐标轴设置
范围设置:
a. axis([xmin xmax ymin ymax])设置坐标轴在指定的区间
b. axis auto 将当前绘图区的坐标轴范围设置为MATLAB自动调整的区间
c. axis manual 冻结当前坐标轴范围,以后叠加绘图都在当前坐标轴范围内显示
d. axis tight 采用紧密模式设置当前坐标轴范围,即一用户数据范围为坐标轴范围
比例:
a. axis equal 等比例坐标轴
b. axis square 以当前坐标轴范围为基础,将坐标轴区域调整为方格形
c. axis normal 自动调整纵横轴比例,使当前坐标轴范围内的图形显示达到最佳效果
范围选项和比例设置可以联合使用,默认的设置为axis auto normal
4.坐标轴刻度设置
set(gca, ’XTick’, [0 1 2]) X坐标轴刻度数据点位置
set(gca,'XTickLabel',{'a','b','c'}) X坐标轴刻度处显示的字符
set(gca,'FontName','Times New Roman','FontSize',14)设置坐标轴刻度字体名称,大小
‘FontWeight’,’bold’ 加粗 ‘FontAngle’,’italic’ 斜体
对字体的设置也可以用在title, xlabel, ylabel等中
5.图例
legend('a','Location','best') 图例位置放在最佳位置
6.更多的设置可以在绘图窗口中打开绘图工具,Inspector… 中查找
http://hi.baidu.com/monkeyking_fu/blog/item/5e9c65160654b956f2de325a
Various line types, plot symbols and colors may be obtained with
PLOT(X,Y,S) where S is a character string made from one element
from any or all the following 3 columns:
http://www.ilovematlab.cn/thread-12702-1-1.html
在使用Matlab时,经常需要将得到的数值表达成二维或三维图像。
plot(vector1,vector2)可以用来画两个矢量的二维图,例如
x=1:0.1:2*pi;
plot(x,sin(x))可以画正弦函数在0-2pi的上的图像。
plot函数可以接一些参数,来改变所画图像的属性(颜色,图像元素等)。下面是一些属性的说明
例如,plot(x,y,'.r')表示用点来画图,点的颜色是红色。
http://gdcxb2007.blogbus.com/logs/46319055.html
plot函数可以接一些参数,来改变所画图像的属性(颜色,图像元素等)。下面是一些属性的说明
·
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文件。后面一段是对应的翻译和说明
(以上几个都是将图例标识放在框图内)
(以上几个将图例标识放在框图外)
还是用上面的例子
legend('sin','cos','location','northwest')可以将标识框放置在图的左上角。
来源网址: