Matplotlib plot zooming with scroll wheel

This should work. It re-centers the graph on the location of the pointer when you scroll. import matplotlib.pyplot as plt def zoom_factory(ax,base_scale = 2.): def zoom_fun(event): # get the current x and y limits cur_xlim = ax.get_xlim() cur_ylim = ax.get_ylim() cur_xrange = (cur_xlim[1] – cur_xlim[0])*.5 cur_yrange = (cur_ylim[1] – cur_ylim[0])*.5 xdata = event.xdata # get …

Read more