python - 如何删除/修改熊猫数据框图表上的轴标题?
问题描述
我正在从熊猫数据框中绘制图表,但无法删除图表上方显示“camis”的文本框,也无法更改各种轴标签。我怎么能这样做?
我试图修改所有函数参数并在这个论坛上到处查看,但没有任何内容会删除文本框或更改/添加 y 轴标签。
我正在使用以下代码:
plot2df = df.groupby("food")["camis"].count() / df_cleaned.groupby("food")["camis"].count()
plot2df.plot(kind="bar",subplots = True, figsize=(4,4),ylim = (0.5,1))
附上图片也是
解决方案
df.plot() 函数返回一个matplotlib
对象。您可以在该对象上设置轴标题。
plot = plot2df.plot(kind="bar", subplots=True, figsize=(4, 4), ylim=(0.5, 1))
plot.set(xlabel="x axis title", ylabel="y axis title")
plot.show()
绘图的主标题也可以df.plot()
使用 'title' 参数添加到函数中:
plot2df.plot(kind="bar", subplots=True, figsize=(4, 4),
ylim=(0.5, 1), title="Add your title")
推荐阅读
- c++ - 你可以在 C++ 中使用类名作为变量名吗
- php - Laravel 相对路径在 localhost 上未按预期工作
- android - 使用 Xamarin Forms 在 Android 10+ 中启动热点
- c# - 绕过gridview上不受信任的ssl链接
- google-bigquery - NetSuite 到 Google BigQuery
- gml - gamemaker 2.0 中的碰撞失败
- prometheus - 为什么 Alertmanager 无法向 slack 发送警报
- javascript - 新用户输入后重新渲染页面
- excel - 将一个工作表中的一行附加到不同工作簿中的工作表
- ios - 如何将 curl Plaid 请求转换为 swift