Spyder is not displaying Matplotlib Plot inline
See original GitHub issueProblem Description
Not able to display Matplotlib plot inline in Spyder.
What steps reproduce the problem?
Running the follow ing Python program in Spyder:
“”" Spyder Editor
This is a temporary script file. “”"
import matplotlib.pyplot as plt
import numpy as np
plt.switch_backend('QT5Agg')
plt.style.use("ggplot")
t = np.arange(0.0, 2.0, 0.1)
s = np.sin(2 * np.pi * t)
s2 = np.cos(2 * np.pi * t)
plt.plot(t, s, "o-", lw=4.1)
plt.plot(t, s2, "o-", lw=4.1)
plt.xlabel("time (s)")
plt.ylabel("Voltage (mV)")
plt.title("Simple plot $\\frac{\\alpha}{2}$")
plt.grid(True)
plt.savefig("test.png")
plt.show()
What is the expected output? What do you see instead?
I expected to see my plot inline in Spyder, I get the plot in a separate Python window. See below:
### Paste Traceback/Error Below (if applicable)IPython console displayed:
Python 3.8.1 (default, Jan 8 2020, 16:15:59)
Type "copyright", "credits" or "license" for more information.
IPython 7.20.0 -- An enhanced Interactive Python.
runfile('/Users/user/temp.py', wdir='/Users/user')
Versions
- Spyder version: 4.2.1
- Python version: 3.8.5
- Qt version: 5.9.7
- PyQt version: 5.9.2
- Operating System name/version: Mac OS X, Big Sur (11.2)
Dependencies
N/A
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Plot inline or a separate window using Matplotlib in Spyder IDE
I know that in Spyder, click Tools, Preferences, Ipython Console, Graphics and under Graphics Backend select “automatic” instead of “inline”.
Read more >Visualisation and plotting with Matplotlib - wradlib
%matplotlib inline turns on “inline plotting”, where plot graphics will appear in your notebook. This has important implications for interactivity: for inline ......
Read more >How do I get interactive plots again in Spyder/Ipython ...
To get interactive plots, we need to activate the figure. Using plt.ioff() and plt.ion(), we can perform interactive actions with plot.
Read more >Interactive figures — Matplotlib 3.6.2 documentation
Creates a new empty Figure or selects an existing figure. pyplot.subplots ... newly created figures and changes to figures are not displayed until....
Read more >Python – Show plots in new window instead of inline (not ...
Go to Tools > preferences > IPython console > Graphics > Graphics backend > Backend: Automatic After this don't forget to restart the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you. Between commenting out plt.switch_backend( ‘QT5Agg’ ), setting Backend to Inline and restarting the kernel did the trick. I appreciate the help from all the contributors to this thread.
Sam Dupree.
On February/10/2021 00:06:59, Carlos Cordoba wrote:
Hey @OrbitalMechanic, thanks for reporting. You’re changing the backend to Qt in this line of the code you posted above:
so that’s why you’re not getting inline plots in Spyder. If you comment it, you’ll see your plot in our Plots pane.