【问题标题】:Matplotlib - Values on top of bar chart is in exponential formMatplotlib - 条形图顶部的值呈指数形式
【发布时间】:2022-07-06 17:24:30
【问题描述】:

我使用 Matplotlib 绘制了一个条形图。我还使用下面的代码在条形图顶部添加了值

fig, ax = plt.subplots()
fig.set_size_inches(15,2.5)
ax.barh(y = fig_1['member_casual'], width = fig_1['ride_id'], color = ['orange','lightcoral'], height = 0.8)
ax.set_xlabel("No. of rides")
ax.set_xlim(xmin = 0, xmax = 3500000)
ax.set()
ax.get_xaxis().get_major_formatter().set_scientific(False)

for bars in ax.containers:
    ax.bar_label(bars)
fig.tight_layout()

我正在以指数形式获取顶部条形的值。我想要简单的数字。

【问题讨论】:

    标签: python matplotlib


    【解决方案1】:

    你可以试试添加这个:

    ax.ticklabel_format(useOffset=False, style='plain')
    

    【讨论】:

      猜你喜欢
      • 2019-01-25
      • 2014-09-21
      • 2022-01-23
      • 2017-03-25
      • 1970-01-01
      • 2017-07-29
      • 2023-02-10
      • 2017-06-04
      • 1970-01-01
      相关资源
      最近更新 更多