0

For some reason plots are generated when i run a single line (F9 in Spyder). So in the sequence hereunder first a line plot is generated. The second line generates an empty plot,but with the y-label,and the plt.show() does nothing. Yesterday i tried making a very simple animation. used export to file. I since then made a total new installation. Reinstalled Anaconda I am using Anaconda, Python 3.9.7 matplotlib 3.4.3, Ipython 7.29.0,spyder 3.9.7

What am I missing?

plt.plot([1, 2, 3, 4])  #this line makes a simple line plot
plt.ylabel('some numbers') #executing thins line makes a new empty plot with the label
plt.show()  #nothing happens

enter image description here

1
  • IPython consolesettings for graphics backend is "Inline". The matplotlib backend used is matplotlib.get_backend() => module://matplotlib_inline.backend_inline' Commented Jan 18, 2022 at 22:43

2 Answers 2

1

(Spyder maintainer here) What you described is the right behavior for the Inline backend, which (as you discovered) is the one you're using.

To change it and create a plot by evaluating different commands one at a time, you need an interactive backend. To set one, please go to the menu

Tools > Preferences > IPython console > Graphics

and select Automatic in the Backend section. After that, you'll be shown a dialog asking you to restart your kernels, to which you need to agree (if that's not the case, just close Spyder and restart it again).

Sign up to request clarification or add additional context in comments.

Comments

0

well , i don't know why exactly but it solves itself if you label the x axis

import matplotlib.pyplot as plt


plt.plot([1, 2, 3, 4])  #this line makes a simple line plot
plt.xlabel('x - axis')
plt.ylabel('some numbers') #executing thins line makes a new empty plot with the label
plt.show()  #nothing happens


The Graph

2 Comments

I am sorry Daniel, this doesn't work. When I execute the line ,in the plots pane in Spyder, an empty graph is shown with the x-axis label. There is somewhere a setting wrong.
Then maybe just add an X axis as usual? plt.plot(X,Y)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.