I have a very strange bug. When opening figures in python, if I hover the mouse cursor above the figure toolbar, everything freezes for about a minute.
I tried:
1. Both from Spyder and using python from bash.
2. Using tkAgg as well as WX and Qt5Agg. By setting before plotting: ,e.g., matplotlib.use('Qt5Agg')
The behavior was similar in all cases.
Would appreciate any advice here. My OS is Ubuntu.
Related
Is there a way to make plots appear in an integrated window on spyder (like in the help space) instead of inline (not practical and no way to zoom) and not as a pop-up window (in my case it always appears on a different space as I use spyder in full screen mode)?
I tried the OSX/Qt4/QT5 settings and they still appear on a separate window.
I would want the same setting as in RStudio where I can go back and forth between plots and not have to deal with windows 'floating' around. Is there a way to work it that way or it does not exist yet?
(Spyder maintainer here) A dedicated pane that shows all plots generated in our consoles is already implemented and will be part of our next major version (Spyder 4, to be released in 2019). Here you can find some screenshots of that pane.
Not too long ago, I posted this issue to the Cmder GitHub page. After two weeks, it has still gone unanswered, so I was hoping to try my luck here.
Basically, I am seeing odd behavior when resizing a window in Cmder, while running bash.
Here is the issue I posted:
To reproduce, open Cmder, and maximize the window:
While emulating a bash console (Bash on Ubuntu on Windows), shrink window size so that the command line (i.e. PS1 environment
variable), wraps to the next line.
Run the command (can be a simple Enter keystroke, as long as 1. is respected).
Maximize window size, and type a command which is longer than the previous shrunken window. Line should wrap over itself.
Can anyone reproduce this behavior? (Running Microsoft Windows
[Version 10.0.15063])
I did not observe the same behavior while emulating cmd.exe.
What's more is that I don't observe this behavior while running the application "Bash on Ubuntu on Windows".
I also tried to see if the same behavior is observed on ConEmu. When I resize the screen, I get the message: "Maximum console size ... was reached Decrease font size in the real console properties", and I'm guessing this might have to do with my high DPI screen. On top of that, I get the same behavior as in Cmder.
Any help on this is greatly appreciated :D
This problem has affected everyone I work with that updated to the currently latest versions below. This only affects ipython plots. The regular python terminal is unaffected by this issue.
Reproduction
import matplotlib.pyplot as plt
plt.plot()
# manually close the window with `x`
Attempting plt.close() also disables the three native OS X window buttons
Workaround
Us the shortcut for closing ipython and then cancel the exit
^+d
Do you really want to exit ([y]/n)? n
Versions
ipython 5.0.0
matplotlib 1.5.1
OS X El Capitan Version 10.11.6
Related
https://github.com/ipython/ipython/issues/9659
Cannot manually close matplotlib plot window
https://github.com/matplotlib/matplotlib/issues/5624/
I have a program written using PyQt and Matplotlib which I am using to display stellar spectra.
The program has a dialog box which I can use to select the required spectra and adjust the X/Y scales and other things.
When changes are made in the dialog box, I have the code do (with matplotlib.pylab imported s plt)
plt.clf()
(replot the newly-selected spectra)
plt.show()
This works fine with older versions of Matplotlib (1.0.0)
However with later versions of Matplotlib (I'm trying 1.3.1), I get strange results. I'm OK the first time round but each subsequent attempt fails to update the plot. I also get lots of messages:
QCoreApplication::exec: The event loop is already running
each time the program tries to invoke the above code and the plot is not updated.
If I change the last part of my code to say
plt.show(False)
That makes the messages go away but the plot is still not updated.
The only way I can make the plot get updated is to change the
plt.clf()
to
plt.close()
but that looks horrible as the display window closes and reopens every time I select a different spectrum.
Is there a better way of doing all this?
I'd rather use the new version of Matplotlib if I can as I also need to use the newer versions of Scipy which has routines in I am using which aren't in the older versions. At the University I'm working it's either "all old" or "all new" as far as versions of the software are concerned.
Thanks for any help you can give.
Solution by OP.
I do:
matplotlib.interactive(True)
and don't bother with any parameters to show() and it does what I want.
I'm new to PythonXY and Matplotlib. I installed PythonXY (v2.7.3.1) in default full mode.
I use the "IPython Qt Console" application.
I draw something using matplotlib.pyplot (imported as plt).
For example. When plt.plot([1,3,2,4]), the figure display in the same IPython console immediately.
If this, I cannot add some other properties, plt.title, plt.xlabel, plt.ylabel, or more. Why? And how can I draw figures in another window, adding more properties, and making the figure not display until plt.show()?
If you select from the Interactive Consoles dropdown on the Python(x,y) Home launcher, "IPython (Qt)" and then click either the Console 2 or cmd.exe button, it should then run IPython (Qt) with the Qt4Agg backend which will allow you to plot in a separate window and apply titles and so on. For more info see What is a backend.
What Python(x,y) in your example above is doing is launching IPython with the pylab inline backend which is different from the standard backends so your commands aren't having any affect, similar behaviour is noted in this issue on github. It doesn't seem possible to change the backend once IPython has been launched with inline. I'm not sure where the Python(x,y) options are set or which script is called to launch the item in the Applications dropdown.
Worth taking a look at Anaconda as a free Python distribution with a scientific focus and regular updates. Anaconda doesn't by default load pylab into IPython so you can choose the backend after launching IPython.
In the IPython command-line interface, the figure is shown and updated at each plot function.
With the inline option, Matplotlib generates an image that automatically inserted in the output line.