plt.xlabel(‘产品名称’)报错‘str’object is not callable的解决方法

import pandas as pd
import matplotlib.pyplot as plt
df=pd.read_excel('产品销售.xlsx')
# 解决中文乱码问题
plt.rcParams['font.sans-serif']=['SimHei']
#设置画布大小
plt.figure(figsize=(10,6))
x=df['产品名称']
height=df['总量']
#设置网络线
plt.grid(axis='y',linestyle='--')
plt.xlabel('产品名称')
plt.ylabel('销量')
plt.title('2022年全年销售总量图',fontsize=18)
plt.bar(x,height)

运行居然报错了…

提示plt.xlabel(‘产品名称’)这一行有错误

报错信息 ‘str’object is not callable

plt.xlabel('产品名称')报错‘str’object is not callable的解决方法

plt.xlabel(‘产品名称’)报错‘str’object is not callable的解决方法

plt.xlabel('产品名称')报错‘str’object is not callable的解决方法

重新运行
x轴 描述信息终于出来了。

plt.xlabel('产品名称')报错‘str’object is not callable的解决方法

以防下次忘记,还是记录下来了。

125jz网原创文章。发布者:江山如画,转载请注明出处:http://www.125jz.com/10980.html

(0)
江山如画的头像江山如画管理团队
上一篇 2022年8月13日 上午10:53
下一篇 2022年8月16日 上午10:34

99%的人还看了以下文章

发表回复

登录后才能评论