Full function analysis of plot function in MATLAB

Source: Internet
Author: User
Tags scalar

Full function analysis of plot function in MATLAB

Function

Two-dimensional curve plotting

Grammar

Plot (Y)
Plot (X1,y1,...)
Plot (X1,y1,linespec,...)
Plot (..., ' PropertyName ', PropertyValue,...)
Plot (Axes_handle,...)
h = Plot (...)
Hlines = Plot (' V6 ',...)

Describe

Plot (y) if Y is an array of MXN, 1:m is x-axis, each column element in Y is y-coordinate, and n-curves are plotted, and if y is a vector of nx1 or 1xn, the y is the horizontal axis of the 1:n, and a 1 curve for the coordinate table if y is the plural, and plot (y) is equivalent to plot Real (y), imag (y)), ignoring imaginary parts of coordinate data in other usage cases.

Plot (X1,y1,...) If x and Y are arrays, draw coordinate data by column, they must have the same dimensions, and if x and Y are one of the vectors and the other is an array, the dimensions equal in x and Y are plotted for multiple curves; if x and Y are one of the scalar and the other is a vector, then the vertical x or y-axis discrete points are drawn.

X

Y

Note

Mxn

Mxn

Draw n curves by column for coordinate data

X and y must have the same dimensions

1xn or NX1

MXN or NXM

Auto-match dimensions draw M-curves in the same direction

Any of four combinations, the same effect

MXN or NXM

1xn or NX1

Ditto

Ditto

1x1

1xn or NX1

Draw Vertical X-axis discrete points

Y can be any vector

1xn or NX1

1x1

Draw Vertical Y-axis discrete points

X can be any vector

Plot (X1,y1,linespec,...) The Curve property of the curve is specified by the parameter Linespec, which includes the Linetype, marker, and color. Plot function supports drawing any group of graphs at the same time

Plot (x1,y1,linespec1,x2,y2,linespec2,...)

This is exactly equivalent to

Plot (X1,Y1,LINESPEC1,...)

Hlod All

Plot (x2,y2,linespec2,...)

The Linetype properties provided in MATLAB are:

Linear

Description

Tag character

Description

Color

Description

-

Solid Line (default)

+

Plus character

R

Red

--

Double Dash

O

Hollow Circle

G

Green

:

Dashed

*

Asterisk

B

Blue

:.

Dot Dash

.

Solid Circle

C

Cyan Green

X

Fork Symbol

M

Magenta

S

Square

Y

Yellow

D

Rhombic

K

Black

^

Upper Triangle

W

White

V

Lower Triangle

>

Right triangle

<

Left Triangle

P

Pentagram

H

Hexagon

It is important to note that when you set the curve Linetype, identifier, and color three item properties in Linespec, the order of the controls is unrestricted and can be omitted or partially omitted. In other words, ' r-.* ', '-.r* ', ' *-.R ' and other forms are equivalent, all of which indicate the use of red dots to connect each node, each node using the "*" logo.

Plot (..., ' PropertyName ', PropertyValue,...) Set the properties of all curve handle objects created by plot, and the line object properties and attribute values are shown in the appendix, which can be set up using Set/get, depending on the example below.

Plot (Axes_handle,...) Specifies the coordinate system, which is the drawing in the Axes_handle coordinate system, which defaults to GCA when not specified.

h = Plot (...) Returns a handle to all the curve handle objects created by plot. Each curve corresponds to a handle, and if there are n curves, h is an array of nx1.

Attention

When plotting multiple curves at the same time, plot cycles through the Colororder and Linestyleorder two properties in the current coordinate system if no curve attributes are specified.

By default, Matlab automatically resets Colororder and Linestyleorder to Defaultaxescolororder and Defaultaxeslinestyleorder each time the plot function is called. default** Properties We can customize, valid until Matlab close, matlab Next start the default** property reset to Factory settings (Factory)

Set (0, ' defaultaxescolororder ', ' r|g|b|k ',...
' Defaultaxeslinestyleorder ', '-|-.| --|: ')

Use the hold all command to prevent the Colororder and Linestyleorder properties from being automatically reset when the plot function is called, instead of using the loop. Note that hold on is just an overlay of graphics that are drawn multiple times (equivalent to Nextplot), but cannot prevent the property from resetting.

In addition, we can set the color and size of identifiers by the following four properties

linewidth--Specifying line widths

markeredgecolor--The edge color of the specified identifier

markerfacecolor--specifying an identifier fill color

markersize--the size of the specified identifier

Note that the above four properties are for all curves in the current coordinate system

Instance

% by dynamic

% See also http://www.matlabsky.com

% 2009.8.20

%

X=1:10;

% two are arrays, must have the same size

X1=[x; X X] ';%10x3

Y1=rand (10,3) +1;%10x3

% one is a vector, the other is an array, automatically matches the dimension equal direction

x2=1:0.1:10;%1x91

Y2=[sin (X2); cos (X2)] ';%91x2

% one is a scalar, the other is a vector, and the vertical axis is plotted as a discrete point

X3=1:10;

y3=-0.5;

Fh=figure (' Numbertitle ', ' off ', ' name ', ' PLOT usability Demo ');% Create Figure object

ah=axes;% Creating Axes objects

H=plot (...% return all curve handles

Ah,...% Specifies the coordinate system, which can be omitted at this time by default GCA

X1,y1,...% coordinate data

'-.^ ',...% curve attribute, can be omitted or partially omitted, at this time automatically selected

X2,y2,...

' m ',...

X3,y3,...

' O ',...% Note this set of data sets Linetype and color is invalid because the default is to draw discrete points

' LineWidth ', 2,...% line width

' Markeredgecolor ', ' K ',...% identifier edge color

' Markerfacecolor ', ' r ',...% identifier fill Color

' Markersize ', 8)% identifier size

Full function analysis of plot function in MATLAB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.