serrajo
serrajo

Reputation: 257

Avoid .show() in pyplot

Given a pandas dataframe df, I would like to be able to do the following from terminal:

df.plot()

and have the plot show up in a window automatically, without having to also to the following:

import matplotlib.pyplot as plt; 
plt.show()

Is it doable?

Upvotes: 1

Views: 45

Answers (1)

john-hen
john-hen

Reputation: 4866

You can enable interactive mode when you're in the interactive Python session:

>>> import matplotlib.pyplot as plt
>>> plt.ion()

You can also make that permanent, so you don't have to type plt.ion() every time you start a new session. Just look for "interactive" in your matplotlibrc configuration file and change that line to this:

interactive: True

Upvotes: 2

Related Questions