我是matplotlib的新手,我想要一张几乎等于this image.的条形图 如您所见,有一条线代表所有条形图的平均值,基本上是2D条形图的精美3D描绘。
我已经有一些代码,但仅适用于2d:
import numpy as np
import matplotlib.pyplot as plt
chart = plt.figure()#figsize=(15, 15)
ax = chart.add_subplot(111)
tags = ('Python', 'C++', 'Java', 'Perl', 'Scala', 'Lisp')
x = np.arange(len(tags))
performance = [5, 8, 6, 4, 2, 1]
avg = []
items = len(performance)
index = 0
while index < items:
avg.append(float(float(sum(performance))/float(len(performance))))
index += 1
ax.yaxis.grid(zorder=0)
ax.set_axisbelow(True)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['bottom'].set_color('#EBE8E6')
ax.spines['bottom'].set_linewidth(2)
#plt.rc('axes', axisbelow=True)
ax.bar(x, performance, align='center', alpha=1, zorder=4, color='#5D9BCF')
ax.plot(x, avg)
plt.xticks(x, tags)
plt.tick_params(
axis='both',
which='both',
bottom=False,
left=False)
chart.savefig('foo.png', bbox_inches='tight')
但是显然我离3D图表不远,请帮助我。