title: Plotting complicated histograms side-by-side
body: <p>I am trying to plot three histograms side-by-side (one row, 3 columns) by using a for loop and iterating over the same code but for a different column. I found two different methods, one is to use the plt.subplots(1, 3, i) and then iterate over i, and the other is to explicitly set fig, ax = plt.subplots() and replace each plt with ax[i] and iterate over that.</p>
  <p>However neither of these works properly because of the additional lines I plot on the histogram(s).</p>
  <p>How could I make this code work for side-by-side plots?</p>
  <pre><code>for parameter in ['k', 'm', 'sig']:
  
          plt.hist(df[parameter], density=True, bins=20, label=parameter, ec='black')
          mn, mx = plt.xlim()
          plt.xlim(mn, mx)
          kde_xs = np.linspace(mn, mx, 301)
          kde = st.gaussian_kde(df[parameter])
          plt.plot(kde_xs, kde.pdf(kde_xs), label=&quot;PDF&quot;)
          plt.legend(loc=&quot;upper left&quot;)
          plt.ylabel('Frequency')
          plt.xlabel([parameter])
          plt.title(f&quot;Histogram for bootstrapped: {parameter}&quot;)
          plt.axvline(df[parameter].mean(), color='r', linestyle='solid', 
          linewidth=2)
  </code></pre>