Matplotlib is a powerful Python module for drawing two-dimensional graphics, which uses the Python language to achieve the ease of use of the MATLAB drawing function, while having a very powerful customization capability. It provides a complete set of command APIs similar to MATLAB and is ideal for interactive mapping. It can also be conveniently embedded in GUI applications as a drawing control. Its documentation is fairly complete, and there are hundreds of thumbnails on the Gallery page, which are available after they are opened. So if you need to draw some kind of diagram, just browse, copy, paste it in this page, basically can be done!
The instance code is as follows:
1. Column Chart
Import Matplotlib.pyplot as Plt
plt.bar (left = 0,height = 1)
plt.show ()
The operation effect is as follows:
2. Pie chart
#! coding:cp936 from
pylab import * Make
a square figure and axes
figure (1, figsize= (6,6))
ax = axes ([0.1, 0.1, 0.8, 0.8]
fracs = [ #每一块占得比例], total for
explode= (0, 0, 0.08) #离开整体的距离, see effect
labels = ' Hogs ', ' Dogs ', ' Logs ' #对应每一块的标志
pie (Fracs, Explode=explode, Labels=labels,
autopct= '%1.1f%% ', shadow=true , startangle=90, colors = ("G", "R", "Y"))
# startangle is the starting angle, the default is 0, starting from here, expand the title in the counterclockwise direction
(' Raining hogs and Dogs ') #标题 show
()
The operation effect is as follows: