Introduced
Matplotlib is Python's most famous drawing library, which provides a complete set of command APIs similar to MATLAB and is ideal for interactive charting. 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, and basically you can do it.
Matplotlib installation method can be clicked here
This article gives you a major introduction to Python use Matplotlib to draw a pie chart method, not to say more, the following look at the code.
Sample code
Import Matplotlib.pyplot as Plt
# The slices would be ordered and plotted counter-clockwise.
Labels = ' frogs ', ' hogs ', ' Dogs ', ' Logs '
sizes = [M, m,]
colors = [' yellowgreen ', ' Gold ', ' lightskyblue ', ' Lightcoral ']
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. ' hogs ')
plt.pie (sizes, Explode=explod E, Labels=labels, colors=colors,
autopct= '%1.1f%% ', Shadow=true, startangle=90)
# Set aspect ratio to is equal so That the pie is drawn as a circle.
Plt.axis (' equal ')
plt.savefig (' d:\\pie.png ')
plt.show ()
Results
Summarize
The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring certain help, if you have questions you can message exchange.