1, set the scale, legend and coordinate label font size
1), provided the size scale
plt.xticks(fontsize=20)
plt.yticks(fontsize=20)
2), the size of the set coordinates
plt.xlabel(..., fontsize=20)
plt.ylabel(..., fontsize=20)
3), set the font size of the legend
plt.legend(..., fontsize=20)
2, add notes (annotate)
plt.annotate('注释', xy=(2, 1), xytext=(3, 4),color='r',size=15,arrowprops=dict(facecolor='g', shrink=0.05))
PS:
- Parameters
xy
is necessary to add comment location.
- Parameter
xytext
is the location of the comment content.
- Parameters
xycoords
are as follows:
parameter |
Introduction |
figure points |
points from the lower left of the figure in the lower left point |
figure pixels |
pixel pixels from the lower left of the figure in the lower left corner of FIG. |
figure fraction |
fraction of figure from lower left portion of the lower left corner of the digital |
axes points |
points from lower left corner of axes from the bottom left coordinate point |
axes pixels |
pixels from lower left corner of axes from the bottom left corner pixel coordinates |
axes fraction |
fraction of axes from lower left portion of the lower left corner |
data |
use the coordinate system of the object being annotated coordinate system (default) using the annotated objects (default) |
polar(theta,r) |
if not native ‘data’ coordinates t |
- Parameters
color
set the font color.
- Parameter
extcoords
Set Text Offset Note:
parameter |
Coordinate System |
‘figure points’ |
The number of points from the lower left corner of the graphic |
‘figure pixels’ |
The number of pixels from the lower left corner of the graphic |
‘figure fraction’ |
0,0 is a graphical lower left corner, upper right corner is 1,1 |
‘axes points’ |
From the lower left corner of the number of domains axis |
‘axes pixels’ |
The number of pixels from the lower left corner of the domain axis |
‘axes fraction’ |
0,0-axis field is the lower left corner, upper right corner 1,1 |
‘data’ |
Domain data using coordinate axis |
- Parameter
size
Settings Comments font size.
- Parameters
verticalalignment
: vertical alignment parameters: [ 'center' | 'top ' | 'bottom' | 'baseline']
- Parameters
horizontalalignment
: horizontal alignment parameters: [ 'center' | 'right ' | 'left']
- Parameters
arrowprops
related parameter information relevant arrow dict types:
use:
arrowprops=dict(facecolor='g', shrink=0.05)
parameter |
Introduction |
width |
the width of the width of the arrow in points arrow points |
headwidth |
The width of the width of the base of the arrow head in points in the base point of the arrow |
headlength |
the length of the arrow head in points of the point of the arrow length |
shrink |
fraction of total length to 'shrink' from both ends of the total length score "shrink" from both ends |
facecolor |
Arrow Color |
- Parameter
bbox
is related to comments about the borders of the dict class parameters:
Use:
bbox=dict(boxstyle='round,pad=0.5', fc='yellow', ec='k',lw=1 ,alpha=0.5)
parameter |
Introduction |
boxstyle |
Block shape |
facecolor (abbreviated fc) |
background color |
edgecolor (abbreviated ec) |
Border Line Color |
edgewidth |
Border Line size |
** PS: ** common block shape are:
- square
- sawtooth
- roundtooth
- raarow
- larrow
- round
- round4
3, text
plt.text(6, 5, "test", size=50, rotation=30.,ha="center", va="center",bbox=dict(boxstyle="round",ec=(1., 0.5, 0.5),fc=(1., 0.8, 0.8),))
- Parameters
x,y
: values represent coordinate values.
- Parameters
color
set the font color.
- Parameters
fontsize
set the font size.
- Parameters
verticalalignment
: vertical alignment parameters: [ 'center' | 'top ' | 'bottom' | 'baseline']
- Parameters
horizontalalignment
: horizontal alignment parameters: [ 'center' | 'right ' | 'left']
- Parameter
xycoords
selecting specified coordinate axis system, the parameters related to the content above.
- Parameters
bbox
to increase the title frame, parameters related to the content above.
Reference Code:
https://github.com/ZhangJiangtao-0108/python in the matplotlib_example.py
file