| 颜色 | 符号 |
|---|---|
| 蓝色 | b |
| 绿色 | g |
| 红色 | r |
| 青色 | c |
| 洋红 | m |
| 黄色 | y |
| 黑色 | k |
| 白色 | w |
| 标记 | 符号 |
|---|---|
| 点 | . |
| 圈 | O |
| 叉 | × |
| 加 | + |
| 星 | * |
| 方形 | S |
| 菱形 | D |
| 上三角 | |
| 下三角 | |
| 左三角 | < |
| 右三角 | > |
| 五角星 | p |
| 六角星 | h |
| 线型 | 符号 |
|---|---|
| 实线 | - |
| 虚线 | – |
| 点线 | : |
| 点画线 | -. |
|属性|解释| |–|–| | LineStyle | 线型 | | LineWidth | 线宽 | | Color | 颜色 | | MarkerType | 标记点的形状 | | MarkerSize | 标记点大小 | | MarkerFaceColor | 标记点内部填充色 | | MarkerEdgeColor | 标记点边缘色 |
xlabel('x','FontName','楷体','FontSize',16);
xlim([-3,3]),指定范围-3~3。诸如此类。|绘图方式|特点说明|语句| |–|–|–| | equal | 横纵轴单位长度相等 |axis equal| | tight | 图的四个边界与曲线边界相抵 |axis image tight| | normal | 正常画图 |axis normal| | xlim/ylim | 限定坐标轴范围 |(与其他三个搭即可,不需要语句)|
figure('Color',colorvalue)。其中'Color'为表示语句,照抄;colorvalue为RGB三元组,是一个由[0,1]中的三个数构成的三元行向量。set(gcf,'color','w')。其中只要改变'w'即可。单引号内部改为由上表指定的颜色表示符号。title('string');title('s1','s2'),s1主标题,s2副标题。legend函数。legend('string1','string2',……);legend(……,'location',location);'location'可以为一个1×4矢量([left bottom width height]),也可以为任意字符串。如果使用MATLAB指定的位置定位则不需要更改。详情请help。x=-pi:pi/20:2.5*pi;
y1=cos(x);
y2=sin(x);
figure
plot(x,y1,'-ro',x,y2,'-.b');
legend('y1','y2','location','northwest');%左上角位置
figure
plot(x,y1,'-ro',x,y2,'-.b');
legend('y1','y2','location','northeast');%左上角位置
figure
plot(x,y1,'-ro',x,y2,'-.b');
legend('y1','y2','location','best');%重叠最小处
figure
plot(x,y1,'-ro',x,y2,'-.b');
legend('y1','y2','location','bestoutside');%绘图区外占用最小面积
| 格式 | 说明 |
|---|---|
| plotyy(x1,y1,x2,y2) | 绘制两条曲线,分以左右为纵轴 |
| plotyy(x1,y1,x2,y2,fun) | 曲线类型由fun指定 |
| plotyy(x1,y1,x2,y2,fun1,fun2) | 两曲线类型分别为fun1,fun2 |
x = linspace(0,10);
y = sin(3*x);
yyaxis left
plot(x,y)
z = sin(3*x).*exp(0.5*x);
yyaxis right
plot(x,z)
ylim([-150 150])
| 格式 | 说明 |
|---|---|
| subplot(m,n,p) | 将图形窗口分为m×n个窗口,在第p个窗口创建子图 |
| subplot(m,n,p,’replace’) | 若在绘制图形时第p个窗口已有坐标系则删除,用新坐标系取代 |
| subplot(m,n,p,’align’) | 对齐坐标轴 |
| subplot(‘position’,[left bottom rright height]) | 在指定位置创建新的子图,并将其设为当前坐标轴,4个参数均采用归一化设置,范围[0,1],左下角为(0,0) |
x=linspace(0,2*pi,200);
y=sin(x);
subplot(2,2,1);
plot(x,y);
y=2.*sin(2.*x).*cos(x);
subplot(2,2,2);
plot(x,y);
y=sin(x)./cos(x);
subplot('position',[0.2 0.05 0.6 0.4]);
plot(x,y);
x=linspace(0,2*pi,200);
y=sin(x);
subplot(2,2,1);
plot(x,y);
y=2.*sin(2.*x).*cos(x);
subplot(2,2,2);
plot(x,y);
y=sin(x)./cos(x);
subplot(2,1,2);
plot(x,y);