import matplotlib.pyplot as plt
import numpy as np
bar_width = 0.4
plt.bar(left = np.arange(len(school)),height = group_ms,label = 'MS', color = 'steelblue',width = bar_width)
plt.bar(left = np.arange(len(school))+bar_width,height = group_gp,label = 'GP', color = 'indianred',width = bar_width)
plt.xticks(np.arange(3)+0.2,school)
plt.legend()
plt.show()
错误代码是:
TypeError Traceback (most recent call last)
<ipython-input-80-f63fd0192e45> in <module>
2 import numpy as np
3 bar_width = 0.4
----> 4 plt.bar(left = np.arange(len(school)),height = group_ms,label = 'MS', color = 'steelblue',width = bar_width)
5 plt.bar(left = np.arange(len(school))+bar_width,height = group_gp,label = 'GP', color = 'indianred',width = bar_width)
6 plt.xticks(np.arange(3)+0.2,school)
TypeError: bar() missing 1 required positional argument: 'x'
数据是
需要将两个学校的数据进行对比