Python 已知x,y的条形图

Python 已知x,y的条形图,python,numpy,matplotlib,Python,Numpy,Matplotlib,我想描绘如下: x = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'] y = [10, 20, 1, 8, 7, 2, 3, 7, 11] 作为条形图(条形图宽度可以是任何数字,只要它们可见) 当我这样做时: plt.figure() plt.bar(x, y) 我得到: TypeError: cannot concatenate 'str' and 'float' objects 为什么??如何查看此项的条形图?此错误表示您传递了错误的类型

我想描绘如下:

x = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']
y = [10, 20, 1, 8, 7, 2, 3, 7, 11]
作为条形图(条形图宽度可以是任何数字,只要它们可见)

当我这样做时:

plt.figure()
plt.bar(x, y)
我得到:

TypeError: cannot concatenate 'str' and 'float' objects

为什么??如何查看此项的条形图?

此错误表示您传递了错误的类型

假设这是pyplot,则bar命令具有以下参数:

left, height, width=0.8, bottom=None, hold=None, **kwargs
您正在为“left”传递一个字符串数组,但需要一个标量数字类型数组。”“左”不是标签,而是坐标。

p.s.使用plt.xticks()设置标签。