1

I am trying to write a piece of code where the title of the figure changes before using ginput. However, it looks like the title changes only after pressing once on the figure, not before.

Here a few lines of code that reproduce the issue.

import matplotlib.pyplot as plt
events = ['1st','2nd']

fig, axs = plt.subplots(nrows = 2, ncols = 1, sharex=True)

for event in events:
    fig.suptitle('{} event.'.format(event))   
    pts = plt.ginput(-1, timeout=0, show_clicks = True)

Do you know why is that?

Flavio.R.
  • 81
  • 1
  • 1
  • 4
  • 1
    Call `fig.canvas.draw()` just before calling `ginput` – JohanC Feb 06 '20 at 12:41
  • Are you using a recent version of matplotlib? Your original code seems to work as expected with the latest version (3.1.3). Possibly the backend you're using also plays a role. – JohanC Feb 06 '20 at 12:47
  • @JohanC Calling fig.canvas.draw() just before calling ginput did the trick! Thanks! – Flavio.R. Feb 06 '20 at 12:58

0 Answers0