y-axis range is not logical (matplotlib python)

Viewed 23

I just specify the x and y axis limitations but the numbers' order is wrong. how can I fix this?

here is my code:

  fig, ax = plt.subplots(figsize=(20,10))
  ax.plot(df.finish_price, label="Stock Values", color = 'blue')
  plt.ylabel("Price", color='b')
  # Generate a new Axes instance, on the twin-X axes (same position)
  ax2 = ax.twinx()
  ax2.plot(df.sentiment, label= 'Sentiment', color='green')
  ax2.tick_params(axis='y', labelcolor='green')
  plt.ylim(bottom = -1)
  plt.ylim(top=1)
  plt.xlabel("Days")
  plt.ylabel("Sentiment", color='g')
  fig.legend()
  plt.show()

and here is the result: enter image description here

as you can see the numbers' order on the right y-axis is wrong.

0 Answers
Related