title: Why does my Pandas plotting function plot independent datasets on top of each other?
body: <p>I have a dataset of phone price data, in lists, and I want to plot a historogram for each model using Pandas and plot method. </p>
  
  <p>When I try to do that using a function, the historograms get plotted on top of each other. So that the first plot is correct, but then the next has two historograms, then the next has all 3 model plots on top of each others and so on.</p>
  
  <pre><code>import pandas as pd
  import matplotlib.pyplot as plt
  
  def printPlot(plotlist, model):
  
      d = pd.DataFrame(plotlist)
  
      d.columns = ['Model','GB','Condition','Price']
  
      lowestquantile = d["Price"].quantile(0.2)
  
      d = d[d["Price"] &gt; lowestquantile]
  
      d.Price.plot(kind='hist')
  
      plotfile = model+".png"
  
      plt.savefig("./plots/"+plotfile)
  
      return
  
  testplot = [[['iPhone 11', ' 64 GB', 'N/A', 5500], ['iPhone 11', ' 256 GB', 'Perfekt', 6500], ['iPhone 11', ' 64 GB', 'Perfekt', 5100], ['iPhone 11', ' 128 GB', 'Perfekt', 6200], ['iPhone 11', ' 64 GB', 'Perfekt', 5700], ['iPhone 11', ' 128 GB', 'Perfekt', 5750], ['iPhone 11', ' 128 GB', 'God', 1111], ['iPhone 11', ' 256 GB', 'Perfekt', 5700], ['iPhone 11', ' 64 GB', 'Perfekt', 5800], ['iPhone 11', ' 64 GB', 'Perfekt', 5200], ['iPhone 11', ' 8 GB', 'N/A', 10], ['iPhone 11', ' 256 GB', 'Perfekt', 4500], ['iPhone 11', ' 256 GB', 'Perfekt', 7000], ['iPhone 11', ' 64 GB', 'Perfekt', 5299], ['iPhone 11', ' 64 GB', 'Perfekt', 6000], ['iPhone 11', ' 256 GB', 'N/A', 50], ['iPhone 11', ' 64 GB', 'Perfekt', 250], ['iPhone 11', ' 128 GB', 'Perfekt', 200], ['iPhone 11', ' 128 GB', 'Perfekt', 6200], ['iPhone 11', ' 128 GB', 'N/A', 6350], ['iPhone 11', ' 64 GB', 'Perfekt', 69], ['iPhone 11', ' 512 GB', 'Perfekt', 100]],[['iPhone XS Max', ' 256 GB', 'Perfekt', 6000], ['iPhone XS Max', ' 512 GB', 'Perfekt', 6750], ['iPhone XS Max', ' 64 GB', 'Perfekt', 5399], ['iPhone XS Max', ' 64 GB', 'God', 3300], ['iPhone XS Max', ' 64 GB', 'Perfekt', 4800], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6666], ['iPhone XS Max', ' 512 GB', 'Perfekt', 6500], ['iPhone XS Max', ' 64 GB', 'N/A', 5500], ['iPhone XS Max', ' 256 GB', 'God', 4700], ['iPhone XS Max', ' 64 GB', 'God', 5500], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6450], ['iPhone XS Max', ' 512 GB', 'N/A', 9000], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6000], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5700], ['iPhone XS Max', ' 512 GB', 'Perfekt', 5345], ['iPhone XS Max', ' 64 GB', 'Perfekt', 6000], ['iPhone XS Max', ' 64 GB', 'Perfekt', 6999], ['iPhone XS Max', ' 64 GB', 'Perfekt', 5500], ['iPhone XS Max', ' 512 GB', 'N/A', 5499], ['iPhone XS Max', ' 512 GB', 'Perfekt', 6500], ['iPhone XS Max', ' 64 GB', 'Rimelig', 3000], ['iPhone XS Max', ' 256 GB', 'N/A', 4700], ['iPhone XS Max', ' 256 GB', 'N/A', 7500], ['iPhone XS Max', ' 256 GB', 'God', 5500], ['iPhone XS Max', ' 256 GB', 'Perfekt', 4000], ['iPhone XS Max', ' 64 GB', 'N/A', 4499], ['iPhone XS Max', ' 64 GB', 'Perfekt', 5000], ['iPhone XS Max', ' 64 GB', 'N/A', 4000], ['iPhone XS Max', ' 512 GB', 'Perfekt', 7000], ['iPhone XS Max', ' 64 GB', 'God', 200], ['iPhone XS Max', ' 256 GB', 'God', 5000], ['iPhone XS Max', ' 64 GB', 'Perfekt', 4400], ['iPhone XS Max', ' 64 GB', 'Perfekt', 5000], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6500], ['iPhone XS Max', ' 512 GB', 'Perfekt', 6000], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6000], ['iPhone XS Max', ' 64 GB', 'N/A', 5000], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6000], ['iPhone XS Max', ' 512 GB', 'Perfekt', 5000], ['iPhone XS Max', ' 256 GB', 'God', 4500], ['iPhone XS Max', ' 64 GB', 'Perfekt', 5000], ['iPhone XS Max', ' 512 GB', 'God', 6500], ['iPhone XS Max', ' 512 GB', 'N/A', 6500], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6500], ['iPhone XS Max', ' 64 GB', 'God', 3799], ['iPhone XS Max', ' 64 GB', 'Perfekt', 5399], ['iPhone XS Max', ' 64 GB', 'N/A', 4599], ['iPhone XS Max', ' 64 GB', 'God', 6000], ['iPhone XS Max', ' 8 GB', 'Perfekt', 130], ['iPhone XS Max', ' 8 GB', 'Perfekt', 130], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6499], ['iPhone XS Max', ' 64 GB', 'Perfekt', 4599], ['iPhone XS Max', ' 64 GB', 'Perfekt', 5500], ['iPhone XS Max', ' 64 GB', 'Perfekt', 6000], ['iPhone XS Max', ' 8 GB', 'Perfekt', 850], ['iPhone XS Max', ' 256 GB', 'God', 5000], ['iPhone XS Max', ' 256 GB', 'God', 6000], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5500], ['iPhone XS Max', ' 512 GB', 'Perfekt', 6499], ['iPhone XS Max', ' 512 GB', 'Perfekt', 5500], ['iPhone XS Max', ' 64 GB', 'God', 5000], ['iPhone XS Max', ' 64 GB', 'God', 4700], ['iPhone XS Max', ' 64 GB', 'God', 4900], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5000], ['iPhone XS Max', ' 512 GB', 'Perfekt', 6200], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5500], ['iPhone XS Max', ' 64 GB', 'Perfekt', 6000], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6000], ['iPhone XS Max', ' 256 GB', 'Perfekt', 4499], ['iPhone XS Max', ' 64 GB', 'God', 4500], ['iPhone XS Max', ' 64 GB', 'Perfekt', 250], ['iPhone XS Max', ' 256 GB', 'Perfekt', 7000], ['iPhone XS Max', ' 64 GB', 'Perfekt', 5000], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5900], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5000], ['iPhone XS Max', ' 256 GB', 'Perfekt', 150], ['iPhone XS Max', ' 64 GB', 'Perfekt', 6000], ['iPhone XS Max', ' 64 GB', 'Perfekt', 6500], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6750], ['iPhone XS Max', ' 64 GB', 'God', 4000], ['iPhone XS Max', ' 256 GB', 'God', 6000], ['iPhone XS Max', ' 64 GB', 'Perfekt', 6000], ['iPhone XS Max', ' 512 GB', 'N/A', 7000], ['iPhone XS Max', ' 64 GB', 'Perfekt', 5000], ['iPhone XS Max', ' 64 GB', 'Perfekt', 4999], ['iPhone XS Max', ' 256 GB', 'God', 100], ['iPhone XS Max', ' 256 GB', 'God', 5000], ['iPhone XS Max', ' 256 GB', 'God', 5000], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6199], ['iPhone XS Max', ' 512 GB', 'Perfekt', 7500], ['iPhone XS Max', ' 64 GB', 'N/A', 6000], ['iPhone XS Max', ' 64 GB', 'Perfekt', 4400], ['iPhone XS Max', ' 64 GB', 'Perfekt', 4500], ['iPhone XS Max', ' 512 GB', 'God', 6500], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5400], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5500], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5000], ['iPhone XS Max', ' 64 GB', 'God', 4000], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5800], ['iPhone XS Max', ' 64 GB', 'Perfekt', 4800], ['iPhone XS Max', ' 512 GB', 'N/A', 250], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5500], ['iPhone XS Max', ' 256 GB', 'Perfekt', 4700], ['iPhone XS Max', ' 512 GB', 'Perfekt', 5800], ['iPhone XS Max', ' 512 GB', 'Perfekt', 7999], ['iPhone XS Max', ' 64 GB', 'N/A', 5300], ['iPhone XS Max', ' 256 GB', 'Rimelig', 5500], ['iPhone XS Max', ' 64 GB', 'Perfekt', 4995], ['iPhone XS Max', ' 256 GB', 'God', 4800], ['iPhone XS Max', ' 64 GB', 'Perfekt', 4200], ['iPhone XS Max', ' 512 GB', 'Perfekt', 7000], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6499], ['iPhone XS Max', ' 256 GB', 'Perfekt', 4999], ['iPhone XS Max', ' 64 GB', 'N/A', 4599], ['iPhone XS Max', ' 64 GB', 'Perfekt', 6000], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5999], ['iPhone XS Max', ' 512 GB', 'Perfekt', 6999], ['iPhone XS Max', ' 256 GB', 'God', 4200], ['iPhone XS Max', ' 64 GB', 'God', 4300], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6499], ['iPhone XS Max', ' 64 GB', 'Perfekt', 5500], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6500], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6900], ['iPhone XS Max', ' 64 GB', 'Perfekt', 6000], ['iPhone XS Max', ' 64 GB', 'Rimelig', 4500], ['iPhone XS Max', ' 64 GB', 'Perfekt', 5500], ['iPhone XS Max', ' 64 GB', 'Perfekt', 6000], ['iPhone XS Max', ' 256 GB', 'God', 280], ['iPhone XS Max', ' 512 GB', 'Perfekt', 6900], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5800], ['iPhone XS Max', ' 8 GB', 'Perfekt', 150], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6999], ['iPhone XS Max', ' 64 GB', 'Perfekt', 4800], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6999], ['iPhone XS Max', ' 512 GB', 'Perfekt', 6250], ['iPhone XS Max', ' 256 GB', 'Perfekt', 7000], ['iPhone XS Max', ' 256 GB', 'God', 4999], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6999], ['iPhone XS Max', ' 256 GB', 'Perfekt', 6999], ['iPhone XS Max', ' 512 GB', 'Perfekt', 50], ['iPhone XS Max', ' 512 GB', 'Perfekt', 6500], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5700], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5000], ['iPhone XS Max', ' 512 GB', 'Perfekt', 7000], ['iPhone XS Max', ' 64 GB', 'Perfekt', 6200], ['iPhone XS Max', ' 256 GB', 'Perfekt', 7000], ['iPhone XS Max', ' 512 GB', 'Perfekt', 7500], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5500], ['iPhone XS Max', ' 256 GB', 'Perfekt', 7000], ['iPhone XS Max', ' 128 GB', 'Perfekt', 110], ['iPhone XS Max', ' 256 GB', 'Perfekt', 7100], ['iPhone XS Max', ' 256 GB', 'Perfekt', 99], ['iPhone XS Max', ' 256 GB', 'Perfekt', 7400], ['iPhone XS Max', ' 128 GB', 'Perfekt', 99], ['iPhone XS Max', ' 256 GB', 'Perfekt', 7300], ['iPhone XS Max', ' 512 GB', 'Perfekt', 6750], ['iPhone XS Max', ' 64 GB', 'God', 4500], ['iPhone XS Max', ' 256 GB', 'Perfekt', 5000]]]
  
  for plotlist in testplot:
  
      printPlot(plotlist,plotlist[0][0])
  </code></pre>