0

New to matplotlib. Basically, I have 2 axis using ax.twinx(). I have daily data going back 20 years. One of plots (LHS - Red) shows up as expected, but when I add the second plot (RHS - Blue), it doesn't show up as I want it as there is a large variation in the data points.

How can I fix it? I want it to be a smooth line.

When I add the second subplot

This is what I want the blue line to look like:

Before I add the second subplot

coffee_cup
  • 11
  • 1
  • 3
  • 1
    Have you tried plotting the blue line first and then the red to make sure your problem is not in the data? – sai Dec 08 '20 at 11:41
  • @sai yes, if I plot it first, there is still the same problem. I think it is perhaps because the data is very volatile and there are daily data points for over 20 years. – coffee_cup Dec 08 '20 at 11:48
  • 1
    You could try increasing the secondary yaxis limits so that there is less vertical distance between the points on the blue line? – tmdavison Dec 08 '20 at 11:49
  • In additional to what @tmdavison suggested, I would also try graphing rolling averages of the blue line. btw what is "RSI 3D"? – sai Dec 08 '20 at 11:53
  • Thanks for the suggestions. RSI 3D just means the 3 day relative strength indicator signal in finance. For the rolling average method, is there a way to do it quickly in matplotlib? – coffee_cup Dec 08 '20 at 11:59
  • Rolling average with numpy: https://stackoverflow.com/questions/13728392/moving-average-or-running-mean – tmdavison Dec 08 '20 at 12:25

0 Answers0