mpl_connect does not write output to jupyter notebook · Issue #6948 · matplotlib/matplotlib · GitHub
Skip to content

mpl_connect does not write output to jupyter notebook #6948

Description

@michalsustr

Hi, I have:

  • notebook 4.2.1
  • matplotlib 1.5.1
  • Python 3.5.2
  • running on Ubuntu

I setup my env through conda.

An example from the docs that uses mpl_connect: http://matplotlib.org/users/event_handling.html#event-attributes

from matplotlib import pyplot as plt

class LineBuilder:
    def __init__(self, line):
        self.line = line
        self.xs = list(line.get_xdata())
        self.ys = list(line.get_ydata())
        self.cid = line.figure.canvas.mpl_connect('button_press_event', self)

    def __call__(self, event):
        print('click', event)
        if event.inaxes!=self.line.axes: return
        self.xs.append(event.xdata)
        self.ys.append(event.ydata)
        self.line.set_data(self.xs, self.ys)
        self.line.figure.canvas.draw()

fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title('click to build line segments')
line, = ax.plot([0], [0])  # empty line
linebuilder = LineBuilder(line)

plt.show()

The print('click', event) line does not show any output in my Jupyter notebooks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions