title: How do you suppress matplotlib output in for loop in Jupyter Notebook?
body: <p>I am looping over a list of DataFrame column names to create barplots using matplotlib.pyplot in a Jupyter Notebook. Each iteration, I'm using the columns to group the bars. Like so:</p>
  
  <pre><code>%matplotlib inline
  
  import pandas as pd
  from matplotlib import pyplot as plt
  
  
  # Run all output interactively
  from IPython.core.interactiveshell import InteractiveShell
  InteractiveShell.ast_node_interactivity = "all"
  
  
  df = pd.DataFrame({'col1': ['A', 'B', 'C'], 'col2': ['X', 'Y', 'Z'], 'col3': [10, 20, 30]})
  
  #This DOES NOT suppress output
  cols_to_plot = ['col1', 'col2']
  for col in cols_to_plot:
      fig, ax = plt.subplots()
      ax.bar(df[col], df['col3'])
      plt.show();
  </code></pre>
  
  <p>The semicolon (';') should suppress text output but when I run the code I get, after the 1st run:</p>
  
  <p><a href="https://i.stack.imgur.com/5wRq5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5wRq5.png" alt="enter image description here"></a></p>
  
  <p>If I run a similar snippet outside of a <code>for</code> loop, it works as expected - the following successfully suppresses output:</p>
  
  <pre><code># This DOES suppress output
  fig, ax = plt.subplots()
  ax.bar(df['col1'], df['col3'])
  plt.show();
  </code></pre>
  
  <p>How do I suppress this text output when looping?</p>
  
  <hr>
  
  <p><strong>Note:</strong></p>
  
  <p>In a previous version of this question, I used the following code to which some of the comments refer, yet I changed it to the above to better show the issue.</p>
  
  <pre><code>cols_to_boxplot = ['country', 'province']
  for col in cols_to_boxplot:
      fig, ax = plt.subplots(figsize = (15, 10))
      sns.boxplot(y=wine['log_price'], x=wine[col])
      labels = ax.get_xticklabels()
      ax.set_xticklabels(labels, rotation=90);
      ax.set_title('log_price vs {0}'.format(col))
      plt.show();
  </code></pre>