GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Installation
  • Documentation
  • Examples
  • Tutorials
  • Contributing

This view

  • Original page
  • New address

GeezerVison is showing matplotlib.org — matplotlib.pyplot.connect — Matplotlib 3.1.2 documentation

You are reading an old version of the documentation (v3.1.1). For the latest version see https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.connect.html
Version 3.1.2
matplotlib
Fork me on GitHub

Navigation

  • index
  • modules |
  • next |
  • previous |
  • home| 
  • contents »
  • API Overview »
  • matplotlib.pyplot »
  • matplotlib.pyplot »

Quick search

Table of Contents

  • matplotlib.pyplot.connect
    • Examples using matplotlib.pyplot.connect

Related Topics

  • Documentation overview
    • API Overview
      • matplotlib.pyplot
        • matplotlib.pyplot
          • Previous: matplotlib.pyplot.colorbar
          • Next: matplotlib.pyplot.contour
Show Page Source

matplotlib.pyplot.connect¶

matplotlib.pyplot.connect(s, func)[source]¶

Connect event with string s to func. The signature of func is:

def func(event)

where event is a matplotlib.backend_bases.Event. The following events are recognized

  • 'button_press_event'
  • 'button_release_event'
  • 'draw_event'
  • 'key_press_event'
  • 'key_release_event'
  • 'motion_notify_event'
  • 'pick_event'
  • 'resize_event'
  • 'scroll_event'
  • 'figure_enter_event',
  • 'figure_leave_event',
  • 'axes_enter_event',
  • 'axes_leave_event'
  • 'close_event'

For the location events (button and key press/release), if the mouse is over the axes, the variable event.inaxes will be set to the Axes the event occurs is over, and additionally, the variables event.xdata and event.ydata will be defined. This is the mouse location in data coords. See KeyEvent and MouseEvent for more info.

Return value is a connection id that can be used with mpl_disconnect().

Examples

Usage:

def on_press(event):
    print('you pressed', event.button, event.xdata, event.ydata)

cid = canvas.mpl_connect('button_press_event', on_press)

Examples using matplotlib.pyplot.connect¶

../../_images/sphx_glr_coords_demo_thumb.png

Coords demo

../../_images/sphx_glr_rectangle_selector_thumb.png

Rectangle Selector

© Copyright 2002 - 2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012 - 2018 The Matplotlib development team.
Last updated on Jan 05, 2020. Created using Sphinx 1.8.5. Doc version v3.1.1-79-g90d53b526.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.