docs: def generation_plot(file, errorbars=True):
      """Plot the results of the algorithm using generation statistics.
      
      This function creates a plot of the generation fitness statistics 
      (best, worst, median, and average). This function requires the 
      matplotlib library.
      
      .. note::
      
         This function only works for single-objective problems.
  
      .. figure:: _static/generation_plot.png
          :alt: Example generation plot
          :align: center
          
          An example image saved from the ``generation_plot`` function (without error bars).
      
      Arguments:
      
      - *file* -- a file-like object representing the statistics file 
        produced by the file_observer 
      - *errorbars* -- Boolean value stating whether standard error bars should 
        be drawn (default True)
  
      """
      import matplotlib.pyplot as plt
      import matplotlib.font_manager 
      
      generation = []
      psize = []
      worst = []
      best = []
      median = []
      average = []
      stdev = []
      reader = csv.reader(file)
      for row in reader:
          generation.append(int(row[0]))
          psize.append(int(row[1]))
          worst.append(float(row[2]))
          best.append(float(row[3]))
          median.append(float(row[4]))
          average.append(float(row[5]))
          stdev.append(float(row[6]))
      stderr = [s / math.sqrt(p) for s, p in zip(stdev, psize)]
      
      data = [average, median, best, worst]
      colors = ['black', 'blue', 'green', 'red']
      labels = ['average', 'median', 'best', 'worst']
      figure = plt.figure()
      if errorbars:
          plt.errorbar(generation, average, stderr, color=colors[0], label=labels[0])
      else:
          plt.plot(generation, average, color=colors[0], label=labels[0])
      for d, col, lab in zip(data[1:], colors[1:], labels[1:]):
          plt.plot(generation, d, color=col, label=lab)
      plt.fill_between(generation, data[2], data[3], color='#e6f2e6')
      plt.grid(True)
      ymin = min([min(d) for d in data])
      ymax = max([max(d) for d in data])
      yrange = ymax - ymin
      plt.ylim((ymin - 0.1*yrange, ymax + 0.1*yrange))  
      prop = matplotlib.font_manager.FontProperties(size=8) 
      plt.legend(loc='upper left', prop=prop)    
      plt.xlabel('Generation')
      plt.ylabel('Fitness')
      plt.show()