Matlab绘图坐标轴的设置.docx

上传人:b****4 文档编号:4189404 上传时间:2023-05-06 格式:DOCX 页数:8 大小:16.88KB
下载 相关 举报
Matlab绘图坐标轴的设置.docx_第1页
第1页 / 共8页
Matlab绘图坐标轴的设置.docx_第2页
第2页 / 共8页
Matlab绘图坐标轴的设置.docx_第3页
第3页 / 共8页
Matlab绘图坐标轴的设置.docx_第4页
第4页 / 共8页
Matlab绘图坐标轴的设置.docx_第5页
第5页 / 共8页
Matlab绘图坐标轴的设置.docx_第6页
第6页 / 共8页
Matlab绘图坐标轴的设置.docx_第7页
第7页 / 共8页
Matlab绘图坐标轴的设置.docx_第8页
第8页 / 共8页
亲,该文档总共8页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Matlab绘图坐标轴的设置.docx

《Matlab绘图坐标轴的设置.docx》由会员分享,可在线阅读,更多相关《Matlab绘图坐标轴的设置.docx(8页珍藏版)》请在冰点文库上搜索。

Matlab绘图坐标轴的设置.docx

Matlab绘图坐标轴的设置

Matlab绘图坐标轴的设置

matlab画图设置(坐标轴、曲线、颜色)

a=linspace(1,2,10)

plot(a,'--pr','Linewidth',1.5,'MarkerEdgeColor','r','MarkerFaceColor','m','MarkerSize',10)

legend('a','Location','best')

title('a','FontName','TimesNewRoman','FontWeight','Bold','FontSize',16)

xlabel('T','FontName','TimesNewRoman','FontSize',14)

ylabel('a','FontName','TimesNewRoman','FontSize',14,'Rotation',0)

axisautoequal

set(gca,'FontName','TimesNewRoman','FontSize',14)

1.曲线线型、颜色和标记点类型

plot(X1,Y1,LineSpec,…)通过字符串LineSpec指定曲线的线型、颜色及数据点的标记类型。

线型颜色数据点标记类型

标识符意义标识符意义标识符意义

-实线r红色+加号

-.点划线g绿色o圆圈

--虚线b蓝色*星号

:

点线c蓝绿色.点

m洋红色x交叉符号

y黄色square(或s)方格

k黑色diamond(或d)菱形

w白色^向上的三角形

v向下的三角形

>向左的三角形

<向右的三角形

pentagram(或p)五边形

hexagram(或h)六边形

2.设置曲线线宽、标记点大小,标记点边框颜色和标记点填充颜色等。

plot(…,?

PropertyName?

PropertyValue,…)

PropertyName意义选项

LineWidth线宽数值,如0.5,1等,单位为points

MarkerEdgeColor标记点边框线条颜色颜色字符,如?

g?

?

b?

MarkerFaceColor标记点内部区域填充颜色颜色字符

MarkerSize标记点大小数值,单位为points

3.坐标轴设置

范围设置:

a.axis([xminxmaxyminymax])设置坐标轴在指定的区间

b.axisauto将当前绘图区的坐标轴范围设置为MATLAB自动调整的区间

c.axismanual冻结当前坐标轴范围,以后叠加绘图都在当前坐标轴范围内显示

d.axistight采用紧密模式设置当前坐标轴范围,即以用户数据范围为坐标轴范围比例:

a.axisequal等比例坐标轴

b.axissquare以当前坐标轴范围为基础,将坐标轴区域调整为方格形

c.axisnormal自动调整纵横轴比例,使当前坐标轴范围内的图形显示达到最佳效果

范围选项和比例设置可以联合使用,默认的设置为axisautonormal

4.坐标轴刻度设置

set(gca,?

XTick?

[012])X坐标轴刻度数据点位置

set(gca,'XTicklabel',{'a','b','c'})X坐标轴刻度处显示的字符

set(gca,'FontName','TimesNewRoman','FontSize',14)设置坐标轴刻度字体名称,大小…FontWeight?

?

bold?

加粗…FontAngle?

?

italic?

斜体

对字体的设置也可以用在title,xlabel,ylabel等中

5.图例

legend('a','Location','best')图例位置放在最佳位置

6.更多的设置可以在绘图窗口中打开绘图工具,Inspector…中查找

VariousLinetypes,plotsymbolsandcolorsmaybeobtainedwith

PLOT(X,Y,S)whereSisacharacterstringmadefromoneelement

fromanyorallthefollowing3columns:

bblue.point-solid

ggreenocircle:

dotted

rredxx-mark-.dashdot

ccyan+plus--dashed

mmagenta*star(none)noLine

yyellowssquare

kblackddiamond

wwhitevtriangle(down)

^triangle(up)

>triangle(right)

ppentagram

hhexagram

在使用Matlab时,经常需要将得到的数值表达成二维或三维图像。

plot(vector1,vector2)可以用来画两个矢量的二维图,例如

x=1:

0.1:

2*pi;

plot(x,sin(x))可以画正弦函数在0-2pi的上的图像。

plot函数可以接一些参数,来改变所画图像的属性(颜色,图像元素等)。

下面是一些属性的说明

bblue(蓝色).point(点)-solid(实线)

ggreen(绿色)ocircle(圆圈):

dotted(点线)

rred(红色)xx-mark(叉号)-.dashdot(点画线)

ccyan(墨绿色)+plus(加号)--dashed(虚线)

mmagenta(紫红色)*star(星号)(none)noLine

yyellow(黄色)ssquare(正方形)

kblack(黑色)ddiamond(菱形)

vtriangle(down)

^triangle(up)

>triangle(right)

ppentagram

hhexagram

例如,plot(x,y,'.r')表示用点来画图,点的颜色是红色。

plot函数可以接一些参数,来改变所画图像的属性(颜色,图像元素等)。

下面是一些属性的说明

bblue(蓝色).point(点)-solid(实线)

ggreen(绿色)ocircle(圆圈):

dotted(点线)

rred(红色)xx-mark(叉号)-.dashdot(点画线)

ccyan(墨绿色)+plus(加号)--dashed(虚线)

mmagenta(紫红色)*star(星号)(none)noLine

yyellow(黄色)ssquare(正方形)

kblack(黑色)ddiamond(菱形)

vtriangle(down)

^triangle(up)

>triangle(right)

ppentagram

hhexagram

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)

xlabel('x');

ylabel('y');

·用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)来指定图例标识框的位置这些是Matlabhelp文件。

后面一段是对应的翻译和说明

'North'insideplotboxneartop

'South'insidebottom

'East'insideright

'West'insideleft

'NorthEast'insidetopright(default)

'NorthWestinsidetopleft

'SouthEast'insidebottomright

'SouthWest'insidebottomleft

'NorthOutside'outsideplotboxneartop

'SouthOutside'outsidebottom

'EastOutside'outsideright

'WestOutside'outsideleft

'NorthEastOutside'outsidetopright

'NorthWestOutside'outsidetopleft

'SouthEastOutside'outsidebottomright

'SouthWestOutside'outsidebottomleft

'Best'leastconflictwithdatainplot

'BestOutside'leastunusedspaceoutsideplot

'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);holdon

x=plot(1:

10,5*rand(10,1),'marker','square','markersize',12,...

'markeredgecolor','y','markerfacecolor',[.60.6],...

'Linestyle','-','color','r','linewidth',2);holdofflegend([b,x],'Carrots','Peas','Peppers','GreenBeans',...

'Cucumbers','Eggplant')

 

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2