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
Ocean Red
S (square)
Square
Y
Yellow
D
Rhombic
K
Black
^
Upper Triangle
W
White
V
Lower Triangle
>
Right triangle
<
Left Triangle
P (Pentagram)
Pentagram
H (hexagram)
Hexagonal square Pentagram Five-angle hexagram hexagonal shape
Note: Matlab palette color intensity [0,1],0 represents the darkest, 1 represents the brightest. common color RGB value -------------------------------------------- Color & Nbsp; r G b color r g B ------------------------- ------------------- Black 0 0 1 Magenta 1 0 &NB Sp 1 White 1 1 1 cyan 0 1 1   ; Red 1 0 0 Blue 0.67 0 1 Green 0 1 0 Orange 1 0.50 Blue 0 0 1 &NBSP;&NB SP; crimson 0.5 0 0 Yellow 1 1 0 Gray 0.5 0. 50.5 -------------------------------------------- &NBSP;&NBSP; functions to produce standard palette ------------------------------------------------- function name Palette ------------------------------------------------- Hsv color saturation, Start with red and end with red Hot Black-red-yellow-white Cool cyan and Magenta chroma Pink Pink chroma Gray linear grayscale bon e with blue grayscale Jet &NBSP;&NBSP;HSV A variant, starting with blue, ending with blue copper Line copper chroma Prim Triple prism, alternating red, orange, yellow, green and sky blue - Flag nbsp Alternating red, white, blue and black-------------------------------------------------- by default, invoking the above function Ash produces a 64x3 palette, The user can also specify a palette size.
Matlab draws more lines, the color of the line to the image of the picture is a great impact.
Jonathan C. Lansey provides a simple and easy-to-use function for drawing different colors on different lines. Matlab-code
Examples demonstrating thecolors.
% linecolors n=6; X =linspace (0,pi*3,1000); Y =bsxfun (@ (x,n) sin (x+2*n*pi/n), X. ', 1:n); C =linspecer (N); Axes (' nextplot ', ' replacechildren ', ' Colororder ', C); Plot (x,y, ' linewidth ', 5) Ylim ([-1.1 1.1]);
% SIMPLER line Colorexample N = 6; X =linspace (0,pi*3,1000); C =linspecer (N) Holdoff; Forii=1:n Y =sin (x+2*ii*pi/n); Plot (x,y, ' Color ', C (ii,:), ' LineWidth ', 3); Hold on; End
% colormapexample A =rand (15); Figure Imagesc (A); % Defaultcolormap figure; Imagesc (A); ColorMap (Linspecer); % Linspecer ColorMap
Note: C is the generated RGB color (very easy to use)
Code download address (Baidu Network disk address): Linspecer
Usage
Grid open gridlines-dotted line
The hold on command is used to add a new graphic to a drawn graphic
1 x=0:0.001:10; X coordinates of 0 to 10 of 1000 dots (every 0.001 draw a point)
Y=sin (x); % of corresponding y coordinates
Plot (x,y); % drawing
Note: The MATLAB drawing is actually the tracing line, so if the point obtained is not dense, the drawing comes out to become the lines chart, please test the
2 Y=sin (10*x);
Plot (X,y, ' r: ', X,y, ' B ')% draw two functions at the same time
3 To change the color, add the relevant string to the following coordinates:
X=0:0.01:10;
Plot (X,sin (x), ' R ')
4 to change both the color and the graph style (line style), you can also add related strings after the coordinate pair:
Plot (X,sin (x), ' r* ')
5 Using the axis ([Xmin,xmax,ymin,ymax]) function to adjust the range of the diagram axis
Axis ([0,6,-1.5,1])
6 Matlab can also add various annotations and processing of graphics: (see table above)
Xlabel (' x axis '); % x Axis annotation
Ylabel (' Y axis '); % y-axis annotation
Title (' cosine function '); % Graphic Title
Legend (' y = cos (x) '); % graphic annotation
Gtext (' y = cos (x) '); % graphic annotation, positioning the annotation position with the mouse
Grid on; % Display Gridlines
7 Draw Ellipse
A = [0:pi/50:2*pi] '; % angle
X = cos (a) *3; % parametric equation
Y = sin (a) *2;
Plot (x,y);
Xlabel (' x '), Ylabel (' Y ');
Title (' Ellipse ')
8 Draw the curve of the function at 0≤x≤1.
X=0:0.1:1
Y=x.*exp (-X)% Why use dot operations. What if it doesn't happen?
Plot (X,y), Xlabel (' x '), Ylabel (' y '), title (' Y=x*exp (x) ')
9 Draw the attenuation oscillation curve with its enveloping line and. The range of values for T is [0, 4π].
T=0:pi/50:4*pi;
Y0=exp (-T/3);
Y=exp (-T/3). *sin (3*t);
Plot (t,y, ' R ', T,y0, ': B ', T,-y0, ': B ')%-R for Red solid line,: B means blue dot line, see table
Grid
10 set up several coordinate systems on the same screen, using subplot (m,n,p) command; Divide a picture into MXN graphics area, p represents the current area number, and each area is painted with a graph, as
X=linspace (0,2*pi,30); Y=sin (x); Z=cos (x);
U=2*sin (x). *cos (x); V=sin (x)./cos (x);
Subplot (2,2,1), Plot (x,y), axis ([0 2*pi-1 1]), title (' Sin (x) ')
Subplot (2,2,2), Plot (x,z), axis ([0 2*pi-1 1]), title (' cos (x) ')
Subplot (2,2,3), Plot (x,u), axis ([0 2*pi-1 1]), title (' 2sin (x) cos (x) ')
Subplot (2,2,4), Plot (x,v), axis ([0 2*pi-20]), title (' Sin (x)/cos (x) ')