4

I recently started studying python and matplotlib. The problem I face is that I always get a black window as a plot output.

See simple code below.

import numpy as np
import matplotlib.pyplot as plt
import pylab


x = np.arange(0, 5, 0.1)
y = np.sin(x)

#plot the x and y and you are supposed to see a sine curve
plt.plot(x, y)

pylab.show()

screenshot

I get the same result executing code samples from matplotlib pages. Does anyone have any idea where this comes from and how to overcome this?

I'm using the Operating system Linux Mint.

8
  • Sorry ! Operating system Linx Mint Commented Jun 17, 2017 at 18:19
  • Actually the use of pylab is discouraged, so try plt.show() instead, maybe it'll help? matplotlib.org/faq/… Commented Jun 17, 2017 at 18:34
  • Same result, black window. Commented Jun 17, 2017 at 18:36
  • Can you try to get matplotlib.get_backend() in python shell? You may miss some libraries. See pyimagesearch.com/2015/08/24/… Commented Jun 17, 2017 at 18:41
  • executing matplotlib.get_backend() output 'TkAgg' Commented Jun 17, 2017 at 18:48

1 Answer 1

1

I executed code in python shell and it works, the problem comes executing code in python editors. I worked with two different editors.

enter image description here

Best regards

Robert

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

1 Comment

Which editors were you using?

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.