Prior to MATLAB programming, drawing is always a very important part, here to tidy up the usual drawing functions for backup.
One or two-dimensional curves and graphs
MATLAB provides a variety of drawing commands for two-dimensional graphics
Command name |
Meanings and functions |
Area |
surface area graph; Mainly used for expressing proportion, composition |
Bar |
A histogram; used primarily for statistical data. |
Compass |
X-ray diagram; mainly for direction and speed |
Feather |
Feather chart; mainly for speed |
hist |
Frequency histogram; mainly used for statistics |
Pie |
Two-dimensional pie chart; statistical data polar form |
Plot |
Basic two-dimensional curve graphics directive |
Polar |
Draw a curve in polar coordinates |
Quiver |
Two-dimensional arrow diagram; Mainly used for field strength, flow direction |
Rose |
Frequency sector graph; Mainly used for statistics |
Stairs |
Ladder diagram; Mainly used for sampling data |
Stem |
Two-dimensional rod diagram; Mainly used for discrete data |
1. Two-dimensional image basic command plot
(1), Basic call format plot (x, y, ' s ')
This is the most classic and basic invocation format for the plot command. The input amount of the command (x, y, ' s ') is called a planar drawing ternary group. They specify the geometric position, point shape, line style, and color of the planar curve, respectively.
1. Curve Linetype, color, and marker point types
Plot (X1,y1,linespec, ...) specifies the line style, color, and marker type of the data point for the curve through the string linespec.
Symbol |
Significance |
- |
Solid line |
R |
Red |
+ |
Plus |
-. |
Dot Dash |
G |
Green |
O |
Circle |
-- |
Dashed |
B |
Blue |
* |
Asterisk |
: |
Point line |
C |
Blue-Green |
. |
Point |
M |
Magenta |
X |
Cross symbol |
Y |
Yellow |
S |
Square |
K |
Black |
D |
Rhombic |
W |
White |
^ |
Upward triangle |
> |
Triangle to the left |
< |
Triangle to the right |
P |
Pentagon |
H |
Hexagon |
|
|
|
|
|
|
2. Set the curve line width, marker point size, Mark point border color, marker point fill color, and so on.
Plot (..., ' property Name ', Property Value, ...)
Property Name meaning option
LineWidth line width value, such as 0.5,1, Unit is points
Markeredgecolor Mark point border Line color color characters, such as ' G ', ' B ', etc.
Markerfacecolor Mark Point Interior area fill Color color character
Markersize mark point size value in points
3. Axis settings
Range Settings:
A. Axis ([xmin xmax ymin Ymax]) sets the axis in the specified interval
B. Axis Auto Sets the axis range of the current plot area to the automatic adjustment interval for matlab
C. Axis manual freezes the current axis range, and later overlays are displayed within the current axis range
D. Axis tight uses tight mode to set the current axis range, that is, one user data range is an axis range
Proportion:
A. Axis equal and other proportional axes
B. Axis Square adjusts the axis area to a checkered shape based on the current axis range
C. Axis Normal automatically adjusts the scale of the axes to maximize the graphics display in the current axis range
Range options and scale settings can be used in conjunction with the default setting of axis Auto Normal
4. Axis scale Setting
Set (GCA, ' XTick ', [0 1 2]) x axis scale data point location
Set (GCA, ' Xticklabel ', {' A ', ' B ', ' C '}) the characters displayed at the X axis scale
Set (GCA, ' fontname ', ' Times New Roman ', ' FontSize ', 14) sets the axis scale font name, size
' FontWeight ', ' bold ' bold ' fontangle ', ' Italic ' italic
The font settings can also be used in the title, Xlabel, Ylabel, etc.
5. Legend
Legend (' A ', ' location ', ' best ') position of the legend in the optimal position
6. More settings can open the drawing tool in the drawing window, Inspector ... Find in
Http://hi.baidu.com/monkeyking_fu/blog/item/5e9c65160654b956f2de325a.html
Various line types, plot symbols and colors is obtained with
PLOT (x,y,s) where S is a character string made from one element
From any or all the following 3 columns:
b Blue. Point-solid
G Green O circle:dotted
R red X X-mark-. Dashdot
C Cyan + Plus--dashed
M Magenta * STAR (none) No Line
Y Yellow s Square
K Black D Diamond
W White v triangle (down)
^ Triangle (UP)
< triangle (left)
> Triangle (right)
P Pentagram
H hexagram
Http://www.ilovematlab.cn/thread-12702-1-1.html
When using MATLAB, it is often necessary to express the resulting values as two-dimensional or three-dimensional images.
Plot (VECTOR1,VECTOR2) can be used to draw a two-dimensional graph of two vectors, for example
X=1:0.1:2*pi;
Plot (X,sin (x)) can draw an image of the sine function on the 0-2pi.
The plot function can take some parameters to change the attributes (colors, image elements, etc.) of the image being drawn. The following are descriptions of some properties
b Blue (blue). Point (dot)-Solid (solid line)
G Green (green) o Circle (circle): Dotted (dot line)
R Red (red) x X-mark (cross)-. Dashdot (dot draw line)
C Cyan (dark green) + Plus (plus)--dashed (dashed)
M Magenta (Magenta) * STAR (asterisk) (none) No Line
Y yellow (yellow) s Square (square)
K Black (Black) d diamond (Diamond)
V Triangle (down)
^ Triangle (UP)
< triangle (left)
> Triangle (right)
P Pentagram
H hexagram
For example, plot (x, Y, '. R ') indicates that a point is used to draw, and the color of the point is red.
Http://gdcxb2007.blogbus.com/logs/46319055.html
The plot function can take some parameters to change the attributes (colors, image elements, etc.) of the image being drawn. The following are descriptions of some properties
b Blue (blue). Point (dot)-Solid (solid line)
G Green (green) o Circle (circle): Dotted (dot line)
R Red (red) x X-mark (cross)-. Dashdot (dot draw line)
C Cyan (dark green) + Plus (plus)--dashed (dashed)
M Magenta (Magenta) * STAR (asterisk) (none) No Line
Y yellow (yellow) s Square (square)
K Black (Black) d diamond (Diamond)
V Triangle (down)
^ Triangle (UP)
< triangle (left)
> Triangle (right)
P Pentagram
H hexagram
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 ');
· When using MATLAB to draw, it is sometimes necessary to label various icons, for example, "+" for the movement of a, "*" represents the movement of B.
The basic usage of the legend function is
LEGEND (String1,string2,string3, ...)
Separate string 1, String 2, String 3 ... Labeled to the diagram, each string corresponds to an icon for the drawing.
For example:
Plot (X,sin (x), '. B ', X,cos (x), ' +r ')
Legend (' Sin ', ' cos ') so you can put "." Identified as ' sin ' and ' + ' as ' cos '
You can also use Legend (..., ' location ', LOC) to specify the position of the Legend identification box
These are the MATLAB Help files. The following paragraph is the corresponding translation and description
' North ' inside plot box near top
' South ' inside bottom
' East ' inside right
' West ' inside left
' Northeast ' inside top right (default)
' Northwest inside top left
' Southeast ' inside bottom right
' SouthWest ' inside bottom left
' Northoutside ' outside plot box near top
' Southoutside ' outside bottom
' Eastoutside ' outside right
' Westoutside ' outside left
' Northeastoutside ' outside top right
' Northwestoutside ' outside top left
' Southeastoutside ' outside bottom right
' Southwestoutside ' outside bottom left
' Best ' least conflict with data in plot
' Bestoutside ' least unused space outside plot
The ' North ' legend logo is placed at the top of the graph
The ' South ' legend logo is placed at the bottom of the graph
The ' East ' legend logo is placed on the right of the graph
The ' West ' legend logo is placed on the left side of the graph
The ' Northeast ' legend marker is placed on the top right of the graph (default)
' Northwest Legend logo on the top left of the graph
The ' Southeast ' legend logo is placed in the lower right corner of the graph
The ' SouthWest ' legend marker is placed in the lower left corner of the diagram
(All of the above are placed in the diagram of the legend logo)
The ' Northoutside ' legend logo is placed above the outside of the frame