MATLAB 绘图

文章目录

  • 1. 图形对象的理解
    • 1.1 对象间的层次结构
    • 1.2 对象的查询和修改
  • 1. plot
    • Syntax
    • Input Arguments
    • Output Arguments
    • Example
  • 2. 线属性 Line Properties
    • Line
    • Markers
    • Geographic Coordinate Data 地理坐标数据
    • Legend
    • Annotation — Control for including or excluding object from legend
    • 其它
  • 3. 标签、标题、文本、注释、图例
    • xlabel
    • ylabel
    • title
    • text
    • legend
  • 4. 常见命令
    • hold on hold off
    • figure
    • clf reset
    • subplot(m,n,p)
    • grid on grid off
  • 5. axis坐标轴
    • Syntax
    • input Arguments
    • Output Arguments
    • Example
  • 5. 坐标轴轮廓 box
    • Syntax
    • Example
  • 5. 坐标轴属性Axes Properties
    • Font
    • Ticks
    • Rulers
    • Grids
    • Labels
    • Multiple Plots
    • Color and Transparency Maps
    • Box Styling
    • Position
    • View and so on
  • 5. 双Y轴图 yyaxis
    • Syntax
    • Example
  • 6. gca 获得当前图片或坐标轴对象
    • Syntax
    • Example
  • 7. get 查询图形对象属性
    • Syntax
    • Example
  • 8. set设置图形对象属性
    • Syntax
    • Example
  • 9. Figure Properties 图形属性
    • 1. figure
      • Syntax
      • Input Arguments
      • Example
    • 2. gcf 当前图形对象
      • Syntax
      • Example
    • 3. Figure Properties
  • 10. imagesc
    • Syntax
  • 颜色
    • 1. colorbar
      • Syntax
    • 2. colormap
      • Syntax
  • 图框大小四至
  • colorbar函数
    • 默认色带
    • 改变色带方向和位置
    • 逆转色带方向
    • Display Colorbar Ticks on Opposite Side
    • 指定刻度和刻度标签Specify Colorbar Ticks and Tick Labels
    • Label Colorbar
    • Delete Colorbar

1. 图形对象的理解

图形对象是 MATLAB用来创建可视化数据的组件。每个对象都有一个名为句柄 的唯一标识符。使用该句柄,您可以通过设置对象 属性 来操作现有图形对象的特征

1.1 对象间的层次结构

  • ROOt::即电脑屏幕

    • Figure:图窗(窗口)

      • Axes:坐标区 (axis属于axes, 坐标区包含线条、文本、图例以及其他用于表示图形的对象)坐标区是表示 x、 y 和 z 坐标区标 度、刻度线、刻度标签、坐标区标签等对象的单个对象。

通常,使用如 plot、bar、scatter等绘图函数创建图形对象。
MATLAB 绘图_第1张图片
MATLAB 绘图_第2张图片

1.2 对象的查询和修改

点方法
get
set

Example

x = -pi:pi/20:pi;
y = sin(x);

f = figure;         % 图窗对象
p = plot(x,y);      % 一条线条对象
txt1 = text(0.2,0,'sin(x)');   % 文本对象

% 查询对象的所有属性
get(f)       
get(p)        
get(txt1)    

% 修改对象属性
f.Name = 'PLOT 1'   
p.Marker = '*';
txt1.EdgeColor = 'red';

MATLAB 绘图_第3张图片

1. plot

2D line plot

Syntax

plot(X,Y)
plot(X,Y,LineSpec)
plot(X1,Y1,...,Xn,Yn)
plot(X1,Y1,LineSpec1,...,Xn,Yn,LineSpecn)
plot(Y)
plot(Y,LineSpec)
plot(___,Name,Value)
plot(ax,___)
h = plot(___)

Input Arguments

  • X Y : scale, vector, matrix
  • LineSpec: Line style, marker, and color
    没有顺序,不必三个全部指定
Line Style Description
- Solid line (default)
- - Dashed line
: Dotted line
-. Dash-dot line
Marker Description
o Circle
+ Plus sign
* Asterisk
. Point
x Cross
s Square
d Diamond
^ Upward-pointing triangle
v Downward-pointing triangle
> Right-pointing triangle
< Left-pointing triangle
p Pentagram
h Hexagram
Color Description
y yellow
m magenta
c cyan
r red
g green
b blue
w white
b black
  • Name-Value Pair Arguments
    Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair ar

你可能感兴趣的:(MATLAB)