1. Title modification
1. Modify the font size, format, bold, and color of the label:
xlabel('title','FontSize',14,'FontWeight','bold','FontName','Times New Roman','Color',' r');
2. The rotation of the title: xlabel('title','rotation',22);ylabel('title','rotation',-35);
3. Color symbols, line shapes, and marker symbols
color symbol | mark symbol |
---|---|
b blue | . point |
g green | s block |
r red | o circle |
c cyan | x cross |
m magenta | + plus sign |
y yellow | * Asterisk |
k black | d rhombus |
w white | v down triangle |
line symbol | ^ upward facing triangle |
- solid line | < left triangle |
: dotted line | > right triangle |
-. Dotted line | p five-pointed star |
– double dash | h hexagonal star |
Usage: plot(x,y,'--r')
mark | describe | generated markup |
---|---|---|
"o" |
the circle | |
"+" |
plus | |
"*" |
Asterisk | |
"." |
point | |
"x" |
Cross | |
"_" |
horizontal lines | |
"|" |
vertical lines | |
"square" |
square | |
"diamond" |
diamond | |
"^" |
upper triangle | |
"v" |
lower triangle | |
">" |
right triangle | |
"<" |
left triangle | |
"pentagram" |
pentagon | |
"hexagram" |
hexagon | |
"none" |
unmarked | not applicable |
To draw a line graph with markers:
x = linspace(0,10,100); y = exp(x/10).*sin(4*x); plot(x,y,'-o')% wired connection plot(x,y,'o')% only points
x = linspace(0,10,50); y = sin(x); plot(x,y,'-s','MarkerSize',10,... 'MarkerEdgeColor','red',... 'MarkerFaceColor',[1 .6 .6])% change color
plot(x,y,'-*','MarkerIndices',1:10:length(y))% control marker position
x = 1:100; y = rand(100,1); idxmin = find(y == max(y)); idxmax = find(y == min(y)); plot(x,y,'-p','MarkerIndices',[idxmin idxmax],... 'MarkerFaceColor','red',... 'MarkerSize', 15)% mark the maximum and minimum
x = linspace(0,10,25); y = x.^2; p = plot(x,y,'-s'); p.MarkerSize = 10; p.MarkerIndices = 1:5:length(y);% Draw a point every 5
2. Modification of drawing line type, line width and line color
1. plot(X,Y,'g','Linewidth', 1.2)%g is modified to a green line, and Linewidth modifies the drawing line width
2. Triple: plot(x,y,'color',[1 0.2 0]);% color table is put at the end of this article
3. Modification of scale value
1. set(gca,'xticklabel',[]); set(gca,'yticklabel',[]);% does not display the scale value
2. Modify the font size of the scale value, font format: set(gca,'FontSize',12,'Fontname','Times New Roman');
3. Modify the coordinate axis range: axis([5 12 0 5])
4. The Greek alphabet, some symbols
Superscript with ^ (exponent)
Subscript with _ (underscore)
For special characters such as Greek letters, use \ plus pinyin such as
<\leq
>
<<\ll
>>\gg
5. Add text and determine the position of drawing
1. The first thing to set is the text position: text(3.3,-1.8,'Text','Color','black','FontSize',14,'FontName','Times New Roman','FontWeight',' Bold');
2. You can first determine the position of the coordinate axis in the figure: a=axis;
Then get an array [1, 2, 0, 3] (for example), the first value and the second value are the abscissa range, know the position of the coordinate axis and then adjust the text position.
Note: The xy coordinate value of text(1,2,'text') is related to the range of the coordinate axis, for example, the x-axis range is 0-100, and the y-axis range is 0-10000, then
text(50,5000,'text') is located in the middle of the graph, and the axes of different subplots vary depending on the situation.
3. position function
Color comparison table: