亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

文本超出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 關注
  • 139 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號