Sek*_*har 3 python charts matplotlib
任何人都可以帮助我在生成带有爆炸选项的饼图时解决以下错误。ValueError: 'explode' 的长度必须是 'x'
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import datetime as dt
figureObject, axesObject = plt.subplots()
labels = "ABC", "XYZ"
delay = [delay1, delay2]
colors = ("red", "green", "orange", "cyan", "brown",
"grey","blue","indigo", "beige", "yellow")
explode = (0, 0.1, 0, 0)
# Draw the pie chart
axesObject.pie(delay,
explode=explode,
labels=labels,
colors=colors,
shadow=True,
autopct='%1.2f',
startangle=90,
wedgeprops = { 'linewidth' : 2, 'edgecolor' : "cyan" })
plt.legend(patches, labels, loc="best")
# Aspect ratio - equal means pie is a circle
axesObject.axis('equal')
plt.show()
Run Code Online (Sandbox Code Playgroud)
附加信息:我使用的是 anaconda 3.6 版本。我能够在不爆炸的情况下生成饼图,但是当我使用爆炸时,我收到一个错误 - ValueError: 'explode' must be of length 'x'。
请帮助我,如何克服这个问题。
| 归档时间: |
|
| 查看次数: |
8876 次 |
| 最近记录: |