Kendall Jackson
Kendall Jackson

Reputation: 13

Matplotlib Graph not showing up on OSX?

I am currently trying to graph data using Python3 and matplotlib. I am developing on OSx Sierra and when I run, it is not showing up. There are no errors returned. I included plt.show() in my code and it is definitely running. Any help to get this graph showing would be appreciated. Vanilla Python3, edited in Emacs, ran from both IDLE and terminal. Neither work. Thank you.

import matplotlib.pyplot as plt

plt.show()

Does not produce anything, and there are no errors. I have tried plt.switch_backend('MacOSX') and the error persists.

Upvotes: 1

Views: 1366

Answers (1)

Thomas Kühn
Thomas Kühn

Reputation: 9810

Just to wrap up the comments into an answer: pyplot.show() only produces a figure, if a figure has been created. This can be done explicitly by stating

fig = plt.figure()

or implicitly by plotting something (the figure is then created in the background), e.g.

plt.plot([1,2,3])

once plt.show() is called, all currently active figures will be displayed on the screen.

Upvotes: 1

Related Questions