Keep pandas matplotlib plot open after code completes
<p>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?</p>

<pre><code>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()
</code></pre>

<p>Use a <code>plt.show(block=True)</code> command to keep the plotting windows open.</p>

<pre><code>[...]
df1.boxplot()
df1.hist()
plt.show(block=True)
</code></pre>

<p>In my version of matplotlib (1.4.3), <code>block=True</code> is necessary, but that may not be the case for all versions (<a href="http://stackoverflow.com/questions/12358312/keep-plotting-window-open-in-matplotlib">Keep plotting window open in Matplotlib</a>)</p>

python pandas matplotlib