I can't see plot in the console [duplicate] - python

using Spyder 4 which is no longer displaying the Plots pane above the console. I have ensured that the backend is set to Inline but the pane still does not show up.
If anyone knows any solutions, it would be greatly appreciated.

(Spyder maintainer here) You need to go the menu View > Panes and activate the entry corresponding to the Plots pane.

Related

How can you reopen the plots pane in spyder?

On installing Spyder, I deleted the help and plots pane in the top right hand corner of Spyder, leaving only the console on the right. Does anyone know how to reopen these panes after removing them?
thanks
My current console
In the top bar open View > Panes and check Plots.
Also, shortcut Ctrl+Shift+G should also open the Plots window.
Update: I was able to solve this (Jakub Holan has the best answer to try first, but it didn't work for me). Even a soft setting reset from inside spyder didn't work. The solution was to close Spyder, search for "reset spyder settings" in windows navigation search, and open the "reset spyder settings" file.

Interactive plots inside Spyder ipython console

Is it possible to plot interactive graphics with sliders and buttons directly inside the Spyder IPython console and not in a separated window ? I find the inline mode really convenient but no interaction seems possible yet. I tried %matplotlib notebook but an error occurred. Any tips please ?
Thanks !!
(Spyder maintainer here) No, unfortunately that's not possible.

Python: Spyder figure window - can't copy or save

I am running Spyder v3.2.4 in Windows 10.
I have gone to Tools > Preferences > IPython console > Graphics > Graphics Backend > Automatic to get my graphs/figures in separate windows. My question is, can I change the window type used to display these graphics? For example, in the window style I have I cannot copy or print the graphic directly. Instead having to save first. Is there a way around this?
The window style I have is:
(Spyder maintainer here) Plot windows are not generated nor handled by Spyder but by Matplotlib. Unfortunately (as you correctly point out) you can only save plots in them.

How to reinitialize the Python console in PyCharm?

I've seen other IDEs have the option to right click and reinitialize the environment. Does anyone know if this is possible in PyCharm, and if so, how it's done?
There is a little reset button (small square with a curved green arrow can be seen above) on the top left of the console that says "Rerun" as the tool tip; this seems to reset the console.
If you can't see the button, the Toolbar might be hidden. To get the Toolbar you need to right click on the "Python Console" tab, and click on "Show Toolbar"
The other answer is correct, I'm adding a new answer on how to create a shortcut for re-running the console. By default, it doesn't have any shortcut, but you can add it by mapping it in Keymap.
Open Preferences (in Mac: Cmd+,) and search for "rerun"
Add the keyboard shortcut for Rerun by double-clicking the "Rerun" line. As you can see from the image below, I assign Cmd+Shift+O for it.
Now you can rerun the console by using the shortcut and don't have to use your mouse anymore.
Please note that this button does not reset all the variables. But then you can enter in the command prompt: reset.
I had tried "rerun" and found that it didn't reload the new environment.
I suggest that "new console" button could help you to reload the environment that it had installed the new packages.

Plot inline or a separate window using Matplotlib in Spyder IDE

When I use Matplotlib to plot some graphs, it is usually fine for the default inline drawing. However, when I draw some 3D graphs, I'd like to have them in a separate window so that interactions like rotation can be enabled. Can I configure in Python code which figure to display inline and which one to display in a new window?
I know that in Spyder, click Tools, Preferences, Ipython Console, Graphics and under Graphics Backend select “automatic” instead of “inline”. However, this make all the figures to be in new windows. It can be messy when I have a lot of plots. So I want only those 3D plot to be in new windows, but all the other 2D plots remain inline. Is it possible at all?
Thanks!
type
%matplotlib qt
when you want graphs in a separate window and
%matplotlib inline
when you want an inline plot
Go to
Tools >> Preferences >> IPython console >> Graphics >> Backend:Inline, change "Inline" to "Automatic", click "OK"
Reset the kernel at the console, and the plot will appear in a separate window
Magic commands such as
%matplotlib qt
work in the iPython console and Notebook, but do not work within a script.
In that case, after importing:
from IPython import get_ipython
use:
get_ipython().run_line_magic('matplotlib', 'inline')
for inline plotting of the following code, and
get_ipython().run_line_magic('matplotlib', 'qt')
for plotting in an external window.
Edit: solution above does not always work, depending on your OS/Spyder version
Anaconda issue on GitHub. Setting the Graphics Backend to Automatic (as indicated in another answer: Tools >> Preferences >> IPython console >> Graphics --> Automatic) solves the problem for me.
Then, after a Console restart, one can switch between Inline and External plot windows using the get_ipython() command, without having to restart the console.
I have set the IPython console backend set to Automatic in the Spyder preferences.
In my scripts, I can now use switch_backend as either
plt.switch_backend('module://ipykernel.pylab.backend_inline') or plt.switch_backend('Qt5Agg') before each new plot, to make it either inline or separate/interactive.
(Tested with Spyder 4.2.2.)
If you want to look at just 1 or 2 charts you can also try manually undocking them in the plot window. So on the top right corner window
select the 'plots' tab
click the button with 3 horizontal bars
select 'undock'
It'll open the plot in a new window. When you close the window, it docks back.

Categories

Resources