Get the App
SLTechnology News&Howtos  ›  Development  › 

How to draw Pie Chart with plt.pie in python

Shulou Source: shulou.com Published: 2022-06-03 17:42:00 09月22日 Update

This article mainly introduces python how to use plt.pie to draw pie chart, the article is very detailed, has a certain reference value, interested friends must read it!

Description

1. Call plt.pie () to draw and calculate the proportion of each item.

The parameter fracs represents the scale.

2. Explode indicates the distance from the whole circle.

For example, the distance from 0.08.

3. Labels represents the class mark.

4. Shadow=True indicates that the figure is shaded.

5. Startangle indicates the starting angle.

The default value is 0.

Example

#-*-coding: utf-8-*-# By:Eastmount CSDNimport matplotlib.pyplot as plt # proportion of each piece The summation is 100mm = [45,30,25] n = mm [0] + mm [1] + mm [2] a = (mm [0] * 1.003100apporium) b = (mm [1] * 1.05100apporium) c = (mm [2] * 1.05100apt) fracs = [a, b, c] print (a, b, c, n) # the distance from the whole explode= (0,0,0.08) labels ='A','B' 'C' # drawing plt.pie (fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True, startangle=90, colors = ("c", "r", "y")) plt.show () expand the display plate counterclockwise Choose different colors in turn. The above is all the contents of the article "how to draw a pie chart with python with plt.pie". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Scale content graphics articles differences values interests parameters circles examples guys partners summation whole direction more plates knowledge industries angles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MariaDB Microsoft Apple Huawei