Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to draw pie chart, broken line chart and circle chart by Python

Shulou Source: shulou.com Published: 2022-06-01 19:57:27 10月27日 Update

This article mainly introduces how Python draws pie charts, broken lines and circles. It is very detailed and has a certain reference value. Friends who are interested must read it!

Example:

From math import piimport matplotlib.pyplot as plt cat = ['Speed',' Reliability', 'Comfort',' Safety', 'Effieciency'] values = [90,60,65,70,40] N = len (cat) x_as = [n / float (N) * 2 * pi for n in range (N)] ax = plt.subplot (111plt.xticks (x_as) ax.plot (x_as, values, linewidth=1, linestyle='solid', zorder=3) plt.show ()

Import matplotlib.pyplot as pltfrom palettable.colorbrewer.qualitative import Pastel1_7my_dpi=96plt.figure (figsize= (480/my_dpi, 480/my_dpi), dpi=my_dpi) names='groupA', 'groupB',' groupC', 'groupD',size= [12 my_circle=plt.Circle ((0L0), color='white') plt.pie (size, labels=names Colors=Pastel1_7.hex_colors) p=plt.gcf () p.gca (). Add_artist (my_circle) plt.show () import pandas as pdimport matplotlib.pyplot as pltdf = pd.DataFrame ([8 beacons, 1 add_artist 2], index= ['ahem,' baked, 'crested,' d'], columns= ['x']) my_dpi=96plt.figure (figsize= (480/my_dpi, 480/my_dpi), dpi=my_dpi) df.plot (kind='pie', subplots=True, figsize= (8)) plt.show ()

The above is all the contents of the article "how to draw pie charts, broken lines and circles in Python". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Diagrams content articles value interests guys buddies more knowledge examples industry information information channels channels references help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL macOS MariaDB OPPO Reno Microsoft