Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add example of keys to explore 3D data #18221

Copy link
Copy link
@tacaswell

Description

@tacaswell
Issue body actions

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.