I'm trying to draw a plot with doulbe y axis, the code is very simple:
fig = plt.figure()
ax = fig.add_subplot(111)
ax_1 = ax.twinx()
ax.plot(x, y)
ax_1.plot(x_1, y_1)
plt.show()
However, my data contain significant fluctuations that make the left part nearly negligible, so I set x limit to truncate these "noises". The original and truncated plot are shown in below.
My expected plot is like the one below (it took me a minute to find optimum y_lims).
I've found some similar questions how to autoscale y axes, their answers just don't work in my case:
ax.autoscale(True, 'y')
|ax.autoscale_view()
|ax.relim()
Because (maybe) the upper limit is decided by y.max()
which belongs to "noises", are there any ways to autoscale y axes based on the data limit appears on the figure?