1

I have a programme which creates an interactive matplotlib (well, pylab) figure, then waits for a raw_input while letting the user manipulate the plot to manually find the best data.

import pylab as p
p.ion()
p.figure(1)
p.plot(x,y,'.')
cen=float(raw_input('Type centre:'))
dur=float(raw_input('Type duration:'))
depth=float(raw_input('Type depth:'))

If I run this on linux (matplotlib 1.4.3), it works as expected. Running this on my Mac (matplotlib 1.5.0) freezes the pylab window at it's first draw and doesn't let the interactive features work. After something is entered into the raw_input, however, it draws all the preceding interactive clicks. Any ideas?

1

1 Answer 1

2

ion() and raw_input() do not work well together. This is a known problem. In interactive mode pyplot.ion() is using an event handler to wait for keypresses. This breaks when raw_input takes over the input.

You can make it a bit better by adding draw() or show():

import pylab as p
p.ion()
p.figure(1)
p.plot(x,y,'.')
p.show()
cen=float(raw_input('Type centre:'))
dur=float(raw_input('Type duration:'))
depth=float(raw_input('Type depth:')) 
1
  • This does not seem to fix the problem unfortunately.
    – HPOsborn
    Mar 17, 2016 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.