code: def plot_period_transactions(
      model,
      max_frequency=7,
      title="Frequency of Repeat Transactions",
      xlabel="Number of Calibration Period Transactions",
      ylabel="Customers",
      **kwargs
  ):
      
      from matplotlib import pyplot as plt
  
      labels = kwargs.pop("label", ["Actual", "Model"])
  
      n = model.data.shape[0]
      simulated_data = model.generate_new_data(size=n)
  
      model_counts = pd.DataFrame(model.data["frequency"].value_counts().sort_index().iloc[:max_frequency])
      simulated_counts = pd.DataFrame(simulated_data["frequency"].value_counts().sort_index().iloc[:max_frequency])
      combined_counts = model_counts.merge(simulated_counts, how="outer", left_index=True, right_index=True).fillna(0)
      combined_counts.columns = labels
  
      ax = combined_counts.plot(kind="bar", **kwargs)
  
      plt.legend()
      plt.title(title)
      plt.ylabel(ylabel)
      plt.xlabel(xlabel)
      return ax
docs: Plot a figure with period actual and predicted transactions.
  
      Parameters
      ----------
      model: lifetimes model
          A fitted lifetimes model.
      max_frequency: int, optional
          The maximum frequency to plot.
      title: str, optional
          Figure title
      xlabel: str, optional
          Figure xlabel
      ylabel: str, optional
          Figure ylabel
      kwargs
          Passed into the matplotlib.pyplot.plot command.
  
      Returns
      -------
      axes: matplotlib.AxesSubplot