Very late reply but I managed to get it working by lending a code from here:
https://stackoverflow.com/questions/11086724/matplotlib-linked-x-axes-with-autoscaled-y-axes-on-zoom
Nice side effect: it also scales the volume bars, so they to not constantly drown below the main plot on zooming anymore! :D
DISCLAIMER:
I am kind of a beginner in python/matplotlib coding, so no guarantee that it might not introduce a bug or break something.
Upon plotting, it throws the following warning once but it seems to work nevertheless:
RuntimeWarning: All-NaN slice encountered
ylim = min(ylim[0], np.nanmin(yc)), max(ylim[1], np.nanmax(yc))
Feel free to debug this very minor annoyance.
I modified plot.py like so:
Between the library loading and the "class PInfo(object): blocks, add this:
...
from .utils import tag_box_style
def on_xlim_changed(ax):
xlim = ax.get_xlim()
for a in ax.figure.axes:
# shortcuts: last avoids n**2 behavior when each axis fires event
if a is ax or len(a.lines) == 0 or getattr(a, 'xlim', None) == xlim:
continue
ylim = np.inf, -np.inf
for l in a.lines:
x, y = l.get_data()
# faster, but assumes that x is sorted
start, stop = np.searchsorted(x, xlim)
yc = y[max(start-1,0):(stop+1)]
ylim = min(ylim[0], np.nanmin(yc)), max(ylim[1], np.nanmax(yc))
# x axis: emit=False avoids infinite loop
a.set_xlim(xlim, emit=False)
# y axis: set dataLim, make sure that autoscale in 'y' is on
corners = (xlim[0], ylim[0]), (xlim[1], ylim[1])
a.dataLim.update_from_data_xy(corners, ignore=True, updatex=False)
a.autoscale(enable=True, axis='y')
# cache xlim to mark 'a' as treated
a.xlim = xlim
class PInfo(object):
...
And then further down, add this:
# plot subindicators that were created on self
for subind in subinds:
self.plotind(iref, subind, subinds=self.dplotsover[subind],
masterax=ax)
ax.callbacks.connect('xlim_changed', on_xlim_changed)
if not masterax:
# adjust margin if requested ... general of particular
ymargin = ind.plotinfo._get('plotymargin', 0.0)
ymargin = max(ymargin, self.pinf.sch.yadjust)
if ymargin:
ax.margins(y=ymargin)
And here three examples.
Before, full view
Before, zoom (volume out of view and subplot y-axis not zoomed -> way too small)
After "patch" applied -> y-axis auto-zoom
(Zoom is to the one lonely biggest profit point approximately in the middle)
Before_full.png
Before_zoomed.png
After_zoom.png