0

I have an "old" version of python on Windows 7: 2.7.13 and matplotlib 2.2.3 and have stumbled into a problem that might have been fixed in later versions. If so, then I'll upgrade... Has it been solved?

For plotting multiaxes, I have some success with mutiple y-axes. Matplotlib documentation gives three examples, .e.g https://matplotlib.org/gallery/axisartist/demo_parasite_axes2.html

All three work for me, except.... if I choose backend WebAgg then Crtl-C is very flaky. Takes maybe a dozen clicks to finally close the server and even then takes a little while to return me a cursor. If I use TkAgg then I do not have any issue at all. I am fond of the WebAgg interface, so would like to solve this.

But maybe there's something simple to add to the code. I tried plt.draw() before plt.show() did nothing. I tried adding my own SIGINT handler but plt.show overruled it.

Appreciate any thoughts.

Tunneller
  • 381
  • 2
  • 13

1 Answers1

0

Ok, this is bad form to answer my own question. But I've found two solutions:

Enter OSK on run to get the onscreen keyboard and type CTRL-SCRLLK

I think this creates a CTRL-BREAK and that WebAgg is not trying to catch that, but what happens on my terminal is that a ^C sign shows up and immediately the Python exits.

And then life gets better:: Turns out that the three-fingered CTRL-FN-B also works, at least on a Dell Laptop.

And for a third option: I installed pywin32 and then a Windows-specific control handler catches it

import win32api
win32api.SetConsoleCtrlHandler(handler,True)

[edit] This question may have been a duplicate, but still not clear why only triggered on multiple axes, e.g.

Why does ctrl + c not stop tornado server?

Tunneller
  • 381
  • 2
  • 13
  • FYI, it is actually encouraged to answer your own question, provided the question and answer are both of good quality :) – DavidG Nov 16 '18 at 23:35