Matlab作图及图形格式设置

通过汇总个人作图常用操作收藏集(包括[Plot][1]和[axis][2]设置),实现信息共享,便于日后向Python Matplotlib举一反三。

目录


作图流程:

Created with Raphaël 2.1.2 数据(x,y) plot settings 确认? 输出图形 yes no

Matlab相关文档

Plot —— [ 2-D line Plot ]

Axis ——[Axes Properties]

plot函数

plot的用法示例

1、plot(_,Name,Value) :常用于设置线条,将[Plot之LineSpec线条的设置]转化为键值对形式使用
2、plot(X1,Y1,LineSpec1,…,Xn,Yn,LineSpecn)

x = 0:pi/10:2*pi;
y1 = sin(x);
y2 = sin(x-0.25);
y3 = sin(x-0.5);

figure
plot(x,y1,'g',x,y2,'b--o',x,y3,'c*')

3、plot(ax,_)

figure % new figure
ax1 = subplot(2,1,1); % top subplot
ax2 = subplot(2,1,2); % bottom subplot
x = linspace(0,3);
y1 = sin(5*x);
y2 = sin(15*x);

plot(ax1,x,y1)
title(ax1,'Top Subplot')
ylabel(ax1,'sin(5x)')

plot(ax2,x,y2)
title(ax2,'Bottom Subplot')
ylabel(ax2,'sin(15x)')

4、h = plot(_)

x = linspace(-2*pi,2*pi);
y1 = sin(x);
y2 = cos(x);
p = plot(x,y1,x,y2);
p(1).LineWidth = 2;
p(2).Marker = '*';

Plot之LineSpec(线条的设置)

-Line Style

线型 描述
- 默认值(实线)
虚线
点线
-. 虚线-点线

-Marker

标识 描述 标识 描述
o ^ 上三角
+ v 下三角
* 星号 < 左三角
. > 右三角
x p 五角星
s 正方形 h 六角星
d 方片

-Color

颜色 描述 颜色 描述
g 绿色 r 红色
b 蓝色 m 洋红
k 黑色 c 青色
y 黄色 w 白色

-LineWidth:(默认值10)

-MarkerSize:(默认值6)

设置坐标图的格式

利用句柄、键值对的形式设置坐标图格式
例如:

ax=gca;%获得当前坐标图对象的属性,即获取句柄
set(ax,'color','r');%更改坐标图底色
set(ax,'xcolor','g');%设置轴线、轴标签、刻度值颜色

键值对设置

-Appearance

Color

LineWidth (轴轮廓、刻度线、网格线,默认值0.5)
-Individual Axes Appearance

XAxisLocation (bottom,top,origin)
XColor
XLim

-Tick Value and label

XTick
XTickLabel
XTickLabelRotation (设置旋转角度)
xlabel

-Grid

XGrid
GridLineStyle
GridColor
GridAlpha(默认值:0.15)

-Font

FontName(’宋体’,’Times New Romance’)
FontSize(默认值:10)
FontWeight (normal,bold)

-Title,Axis and Legend

title
legend

title('My Title','FontWeight','normal')
ylabel('My y-Axis Label','FontSize',12)
legend({'Line 1','Line 2','Line 3'},'FontSize',12)

猜你喜欢

转载自blog.csdn.net/charie411/article/details/72627821
今日推荐