为了账号安全,请及时绑定邮箱和手机立即绑定

文本超出Figsizeplot.bar

文本超出Figsizeplot.bar

守着星空守着你 2023-12-26 14:49:00
我想修复从我的plot.bar()中得到的str数字而不改变figsize。这个有可能 ?我的代码:ax = dados["NU_IDADE"].value_counts().sort_index().plot.bar(figsize=(25, 10))for p in ax.patches:  percent_label_text = (p.get_height() / len(dados)) * 100  ax.annotate(f'{str(round(percent_label_text, 2 if percent_label_text >= 0.01 else 3))}%', (p.get_x(), p.get_height()), rotation='vertical', xytext=(2, 5), textcoords="offset points")我的情节吧:
查看完整描述

1 回答

?
慕的地10843

TA贡献1785条经验 获得超8个赞

ax.set_ylim(..) 您可以在命令之后尝试plot.bar,这将帮助您自定义 y 轴的最小和最大限制。例如,:

ax = dados["NU_IDADE"].value_counts().sort_index().plot.bar(figsize=(25, 10))

ax.set_ylim([0,22500])


for p in ax.patches:

  percent_label_text = (p.get_height() / len(dados)) * 100

  ax.annotate(f'{str(round(percent_label_text, 2 if percent_label_text >= 0.01 else 3))}%', (p.get_x(), p.get_height()), rotation='vertical', xytext=(2, 5), textcoords="offset points")



查看完整回答
反对 回复 2023-12-26
  • 1 回答
  • 0 关注
  • 36 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信