TrW236
TrW236

Reputation: 387

Cannot plot in Pycharm using matplotlib.pyplot.. The figure showed up and disappeared instantly

In Pycharm

import matplotlib.pyplot as plt
plt.interactive(True)
plt.plot([1,2,3,4])

The figure showed up and disappeared instantly.

How to set the figure to keep showing?

Upvotes: 3

Views: 3418

Answers (2)

ImportanceOfBeingErnest
ImportanceOfBeingErnest

Reputation: 339735

Since you are in interactive mode the figure will not stay open. You may simply not use interactive mode,

import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.show()

or you may turn it off before showing the figure.

import matplotlib.pyplot as plt
plt.interactive(True)
plt.plot([1,2,3,4])
plt.ioff()
plt.show()

Upvotes: 3

Pedro Lobito
Pedro Lobito

Reputation: 99041

Use plt.show(), i.e.:

import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.show()

Upvotes: 2

Related Questions