Я строю серию pandas, представляющую распределение. Индекс - это величина изменения продаж, а значение - это плотность вероятности. Я хотел бы представить это в виде гистограммы и отформатировать обе оси в процентах. Это работает, как и ожидалось, с PercentFormatter
для оси Y (и для обеих осей при построении линейного графика), но не для оси X. Есть ли способ использовать PercentFormatter
для оси X на гистограмме?
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as mtick
s = pd.Series([-0.5,0.5],index=[-0.5,0.5])
fig,ax = plt.subplots()
s.plot.bar(ax=ax)
ax.yaxis.set_major_formatter(mtick.PercentFormatter(1))
ax.xaxis.set_major_formatter(mtick.PercentFormatter(1))
fig,ax = plt.subplots()
s.plot(ax=ax)
ax.yaxis.set_major_formatter(mtick.PercentFormatter(1))
ax.xaxis.set_major_formatter(mtick.PercentFormatter(1))
![bar plot with wrong x-axis](https://i.stack.imgur.com/1UiF9.png)