pandas - 在 Pandas plot() 中指定 y_label
问题描述
我想在下面的 Pandas 绘图函数中指定 y_label,但似乎语法不正确。
row = df.iloc[0].astype(int)
row.value_counts().reindex().plot(ylabel='something').bar()
因为错误是
bar() missing 2 required positional arguments: 'x' and 'height'
如果我使用row.value_counts().reindex().plot().bar()
,没有问题,但也没有 y_label 。我该如何解决?
解决方案
这应该有效:
ax = row.value_counts().reindex().plot(kind='bar')
ax.set_ylabel("something")
推荐阅读
- proxy - 测试带有客户端错误的 Grafana 仪表板:407
- swift - Swift:上传到服务器时加密文件内容并打开它
- python - pyqtgraph鼠标交互:使用鼠标右键或中键缩放到选中框
- android - 有没有办法从Android图像中提取自动标签
- reactjs - 不能改变背景颜色
- c - 如何使用递归二进制搜索返回正确的索引?
- python - 如何在 Seaborn 中为同一图形上的直方图生成两个单独的 Y 轴
- llvm - 将带有参数的函数插入到 appendToGlobalCtors
- css - TailwindCSS 电话断点溢出-x 问题
- xaml - Xamarin Forms:如何在选择/取消选择 FlyoutItem.Icon 时更改它的颜色?