JuliaPy / PyPlot.jl

Plotting for Julia based on matplotlib.pyplot
https://github.com/JuliaPy/PyPlot.jl
MIT License
475 stars 87 forks source link

Having to click twice on buttons in the GUI [MacOSX and tk matplotlib backend] #399

Open MaxandreJ opened 5 years ago

MaxandreJ commented 5 years ago

Hi,

Often when I click on buttons in the figure GUI (like zoom, home, settings...), there's no response, and I need to click on the buttons twice or more to get them to work. It would be great if I could only click on them once and get the desired response!

Best, Max

tkf commented 5 years ago

I can't reproduce this. You better specify your environment like OS, software versions (Julia, Python, PyCall, PyPlot , matplotlib), matplotlib backend, etc. Also check that it works in pure-Python environment (without Julia). If not, you can report it to upstream like matplotlib.

MaxandreJ commented 5 years ago

Hi again @tkf and thanks for your help!

I've found the issue thanks to your guidance. I've also found a workaround, which may be useful for other people. I'm on MacOSX and by default matplotlib uses the macosx backend for plotting, but macosx isn't an available backend for PyPlot.jl. By default, PyPlot used the TkAgg backend on my machine, which had the buggy behaviour I've described in this thread (having to click twice on buttons). This buggy behaviour occurred whether I ran matplotlib from Julia or Python.

The workaround I found was: install the Qt5 backend for python by running pip install PyQt5 in the terminal (in your correct virtual environment if your using one), and run in Julia

using PyCall
pygui(:qt5)

. Then the behaviour with the buttons is correct.

An improvement to this Julia module would be to be able to support the macosx backend, because this procedure isn't very user friendly and the macosx backend is a bit nicer on mac.

Reference : what is a matplotlib backend and list of backends. https://matplotlib.org/tutorials/introductory/usage.html#what-is-a-backend

MaxandreJ commented 5 years ago

The request for supporting the macosx backend of matplotlib is actually an issue raised with PyPlot.jl in 2013: #11 but there's no more activity on it since late 2014...

tkf commented 5 years ago

Great. Thanks for summarizing the situation in macOS!

As mentioned in #11, IPython and ipykernel already support macosx. It's just that some macOS user have to implement it in PyCall...