Q:

Keep pandas matplotlib plot open after code completes

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()

A:

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)

