У меня есть этот код ниже, чтобы отображать тренды акций, и иметь одну ось с двумя осями слева и другую справа от графика для двух акций с разными масштабами.Я не могу понять, как я могу добавить больше акций на график.У меня просто есть 2 акции, но я хотел бы добавить больше.
Как я могу изменить свой код, чтобы добавить больше акций ко второй оси?
fig, ax1 = plt.subplots()
fig = plt.figure(figsize=(6,4))
t = newdf['date']
s1 = newdf['IBM']
ax1.plot(t, s1, 'b-')
ax1.set_xlabel('Dates', fontsize=14)
ax1.set_xticklabels(t, rotation=45)
ax1.legend(loc=0)
ax1.grid()
# Make the y-axis label, ticks and tick labels match the line color.
ax1.set_ylabel('Price', color='b')
ax1.tick_params('y', colors='b')
ax2 = ax1.twinx()
s2 = newdf['AAPL']
ax2.plot(t, s2, 'r-')
ax2.set_ylabel('Price', color='r')
ax2.tick_params('date', colors='r', rotation=90)
ax2.legend(loc=2)
fig.tight_layout()
plt.show()
[![Here is the graph with 2 axis's, with 2 stocks]](https://i.stack.imgur.com/dJqyT.png)
