提问人:Kaaj 提问时间:10/31/2023 最后编辑:WoodfordKaaj 更新时间:10/31/2023 访问量:26
我想将数据框的 x 和 y 绘制为整数和百分比。Y 轴搞砸了。如何修复它以重新排序 y 轴?[复制]
I want to draw a plot of x and y of a data frame as integers and percentages. the y axis messing up. how do I fix it to re-order the y axis? [duplicate]
问:
plt.figure (figsize=(20,30), dpi=80)
plt.scatter (df3['Crude oil average price $ per barrel'],df3['Competition rate'])
plt.xlabel ("Crude oil average price $ per barrel")
plt.ylabel('Competition rate percentage')
绘图在 y 轴上搞砸了,无法排序,因为 cvs 文件不包含浮点数或整数:
答: 暂无答案
评论
PercentFormatter
。df3['Competition rate'
是字符串。df3['Competition rate'] = df3['Competition rate'].str.replace('%', '').astype(float)