python matplotlib use in (ii)

1, set the scale, legend and coordinate label font size

1), provided the size scale

Here Insert Picture Description

plt.xticks(fontsize=20)
plt.yticks(fontsize=20)

Here Insert Picture Description

2), the size of the set coordinates

plt.xlabel(..., fontsize=20)
plt.ylabel(..., fontsize=20)

Here Insert Picture Description

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))

Here Insert Picture Description
PS:

  • Parameters xyis necessary to add comment location.
  • Parameter xytextis the location of the comment content.
  • Parameters xycoordsare 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 colorset the font color.
  • Parameter extcoordsSet 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 sizeSettings Comments font size.
  • Parameters verticalalignment: vertical alignment parameters: [ 'center' | 'top ' | 'bottom' | 'baseline']
  • Parameters horizontalalignment: horizontal alignment parameters: [ 'center' | 'right ' | 'left']
  • Parameters arrowpropsrelated 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 bboxis 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:

  1. square
  2. sawtooth
  3. roundtooth
  4. raarow
  5. larrow
  6. round
  7. 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),))

Here Insert Picture Description

  • Parameters x,y: values represent coordinate values.
  • Parameters colorset the font color.
  • Parameters fontsizeset the font size.
  • Parameters verticalalignment: vertical alignment parameters: [ 'center' | 'top ' | 'bottom' | 'baseline']
  • Parameters horizontalalignment: horizontal alignment parameters: [ 'center' | 'right ' | 'left']
  • Parameter xycoordsselecting specified coordinate axis system, the parameters related to the content above.
  • Parameters bboxto increase the title frame, parameters related to the content above.

Reference Code:

https://github.com/ZhangJiangtao-0108/python in the matplotlib_example.pyfile

Released nine original articles · won praise 2 · views 99

Guess you like

Origin blog.csdn.net/jocker_775065019/article/details/104866492
Recommended