title: Pause python until plot is shown
body: <p>I want Python 3 to wait till the plot was displayed before the <code>print</code> statement is executed. Right now it looks like that:
  <a href="https://i.stack.imgur.com/1ds0I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1ds0I.png" alt="console output" /></a></p>
  <p>This is the relevant part of my code:</p>
  <pre><code>import pandas as pd
  import matplotlib.pyplot as plt
  df = pd.read_csv(filename)
  headers = list(df)
  attribute = str(input(&quot;Which attribute would you like to analyze?\n&quot;))
  attribute_mean = df[attribute].mean()
  attribute_std = df[attribute].std()
  ax = df.plot.bar(x=headers[0], y=str(attribute), label=(&quot;_&quot;+attribute))
  ax.axhline(attribute_mean, color=&quot;red&quot;, label=&quot;mean&quot;)
  ax.axhline((float(attribute_mean) + float(attribute_std)), color=&quot;green&quot;, label=&quot;std&quot;)
  ax.axhline((float(attribute_mean) - float(attribute_std)), color=&quot;green&quot;, )
  ax.legend([&quot;mean&quot;, &quot;+std&quot;, &quot;-std&quot;])
  plt.ylabel(attribute)
  plt.xlabel(headers[0])
  plt.margins(x=0, y=0)
  fig = plt.gcf()
  leg = plt.legend(loc = 'upper right')
  fig.show()
  print(&quot;The presented data showed the following characteristic values:\n&quot;)
  display(df[attribute].describe())
  </code></pre>
  <p>Is there  a way to fix this?</p>