Python绘制饼状图
Python绘制饼状图
import matplotlib.pyplot as plt
import numpy as np
if __name__ == "__main__":
labels = 'A', 'B'
sizes = [9, 18]
explode = (0.1, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
fig1, ax1 = plt.subplots()
ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',
shadow=True, startangle=90)
ax1.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
plt.show()
效果如下: