from matplotlib Import pyplot AS PLT Import matplotlib # set the font size font = { ' Family ' : ' MicroSoft YaHei ' , ' weight ' : ' Bold ' , ' size ' :. 8 } matplotlib.rc ( " font " , ** font) X = Range (0,10 ) Y1 = Range (10,20 ) Y = Range (30,40 ) # set the image size, figsize picture size, dpi pixel image = plt.figure Fig (figsize = (20 is, 10), dpi = 60 ) # save the image plt.savefig ( " ./t1.png " ) # drawing for two graphics with a x-axis, label parameter specifies the legend name, color parameter specifies the line color, linestyle parameter specifies line style, linewidth line thickness, alpha transparency lines plt.plot (X, Y, label = ' first ' , color = ' Red ' , linestyle = " - " , as linewidth =. 5, Alpha = 0.5 ) plt.plot (X, Y1, label = ' second ' , Color = ' Gold ' ) # set scale of axes, a first parameter may be a list, the second parameter It is a string, but must be consistent with the number of first parameters, rotation degrees x scale display rotation plt.xticks (X, Labels = [ " the first number of {} " .format (I) for I in List (X)], rotation = 90 ) plt.yticks (Y) # to add a unit of picture information, and title information plt.xlabel ( ' time ' ) plt.ylabel ( ' speed ' ) plt.title ( ' which is a title ' ) # displays a grid, the grid can be adjusted by adjusting the size of the sparse scale, alpha adjust gridline transparency, lineStyle gridlines style plt.grid (Alpha = 0.4, lineStyle = ' -. ' ) # Add a legend, the legend in the drawing functions to add the name, location can be specified by the legend loc parameter plt.legend (loc = ' Upper left ' ) # Presentation graphics plt.show ()