Я использую комбинацию панд и matplotlib, чтобы построить три значения для нескольких категорий.Мне бы хотелось, чтобы у одного графика была своя собственная ось, а у двух других - общая ось.
Закрыть, но иллюстрирует проблему с тем, почему мне нужны двойные оси:
pd.DataFrame([[1,2,3], [500,600,700], [500, 700, 650]], columns=['foo', 'bar','baz'],
index=['a','b','c']).T.plot(kind='bar')

Вместо этого я бы хотел вторую ось для баров a
.Моя попытка:
smol = pd.DataFrame([[1,2,3], [500,600,700], [500, 700, 650]], columns=['foo', 'bar','baz'],
index=['a','b','c']).T
fig = plt.figure(figsize=(10,5)) # Create matplotlib figure
ax = fig.add_subplot(111) # Create matplotlib axes
ax2 = ax.twinx() # Create another axes that shares the same x-axis as ax.
smol['a'].plot(kind='bar', color='red', ax=ax, width=0.3,
position=1, edgecolor='black')
smol['b'].plot(kind='bar', color='blue', ax=ax2, width=0.3,
position=0, edgecolor='black')
ax.set_ylabel('Small scale')
ax2.set_ylabel('Big scale')
plt.show()

К сожалению, добавление
smol['c'].plot(kind='bar', color='green', ax=ax2, width=0.3,
position=0, edgecolor='black')
дает:

Как сделать так, чтобы b
и c
имели общую ось, но появлялись рядом друг с другом, как в первой попытке?