Closed
Description
This snippet of code from @fermrav:
def move_view(event):
ax.autoscale(enable=False, axis='both') # I have no idea, it this line have some effect at all
## Set nearly similar speed of motion in dependency on zoom
if view_2D:
koef = 4. ## Speed for 2D should be higher
else:
koef = 8. ## speed for 3D should be lower
zkoef = (ax.get_zbound()[0] - ax.get_zbound()[1]) / koef
xkoef = (ax.get_xbound()[0] - ax.get_xbound()[1]) / koef
ykoef = (ax.get_ybound()[0] - ax.get_ybound()[1]) / koef
## Map an motion to keyboard shortcuts
if event.key == "ctrl+down":
ax.set_ybound(ax.get_ybound()[0] + xkoef, ax.get_ybound()[1] + xkoef)
if event.key == "ctrl+up":
ax.set_ybound(ax.get_ybound()[0] - xkoef, ax.get_ybound()[1] - xkoef)
if event.key == "ctrl+right":
ax.set_xbound(ax.get_xbound()[0] + ykoef, ax.get_xbound()[1] + ykoef)
if event.key == "ctrl+left":
ax.set_xbound(ax.get_xbound()[0] - ykoef, ax.get_xbound()[1] - ykoef)
if not view_2D:
if event.key == "down":
ax.set_zbound(ax.get_zbound()[0] - zkoef, ax.get_zbound()[1] - zkoef)
if event.key == "up":
ax.set_zbound(ax.get_zbound()[0] + zkoef, ax.get_zbound()[1] + zkoef)
# print event.key
fig.canvas.mpl_connect("key_press_event", move_view)
should be turned into an example in https://github.com/matplotlib/matplotlib/tree/master/examples/event_handling (including showing how to disable the default keybinding via rcparam
Originally posted by @fermrav in #110 (comment)