0

I am using pandas builtin plotting as per below. However as soon as the plotting method returns, the plot disappears. How can I keep the plot(s) open until I click on them to close?

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt

def plot_data():
    #...create dataframe df1
    pd.options.display.mpl_style = 'default'
    df1.boxplot()
    df1.hist()

if __name__ == '__main__':
    plot_data()

1 Answer 1

2

Use a plt.show(block=True) command to keep the plotting windows open.

[...]
df1.boxplot()
df1.hist()
plt.show(block=True)

In my version of matplotlib (1.4.3), block=True is necessary, but that may not be the case for all versions (Keep plotting window open in Matplotlib)

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

Comments

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.