code: def rmst_plot(
      model,
      model2=None,
      t=np.inf,
      ax=None,
      text_position=None,
      **plot_kwargs,
  ):
      """
      This functions plots the survival function of the model plus it's area-under-the-curve (AUC) up
      until the point ``t``. The AUC is known as the restricted mean survival time (RMST).
  
      To compare the difference between two models' survival curves, you can supply an
      additional model in ``model2``.
  
      Parameters
      -----------
      model: lifelines.UnivariateFitter
      model2: lifelines.UnivariateFitter, optional
          used to compute the delta RMST of two models
      t: float
          the upper bound of the expectation
      ax: axis
      text_position: tuple
          move the text position of the RMST.
  
  
      Examples
      ---------
      .. code:: python
  
          from lifelines.utils import restricted_mean_survival_time
          from lifelines.datasets import load_waltons
          from lifelines.plotting import rmst_plot
  
          df = load_waltons()
          ix = df['group'] == 'miR-137'
          T, E = df['T'], df['E']
          time_limit = 50
  
          kmf_exp = KaplanMeierFitter().fit(T[ix], E[ix], label='exp')
          kmf_con = KaplanMeierFitter().fit(T[~ix], E[~ix], label='control')
  
          ax = plt.subplot(311)
          rmst_plot(kmf_exp, t=time_limit, ax=ax)
  
          ax = plt.subplot(312)
          rmst_plot(kmf_con, t=time_limit, ax=ax)
  
          ax = plt.subplot(313)
          rmst_plot(kmf_exp, model2=kmf_con, t=time_limit, ax=ax)
  
  
  
      """
      from lifelines.utils import restricted_mean_survival_time
      from matplotlib import pyplot as plt
  
      if ax is None:
          ax = plt.gca()
      rmst = restricted_mean_survival_time(model, t=t)
      c = ax._get_lines.get_next_color()
      model.plot_survival_function(
          ax=ax, color=c, ci_show=False, **plot_kwargs
      )
  
      if text_position is None:
          text_position = (np.percentile(model.timeline, 10), 0.15)
      if model2 is not None:
          c2 = ax._get_lines.get_next_color()
          rmst2 = restricted_mean_survival_time(model2, t=t)
          model2.plot_survival_function(
              ax=ax, color=c2, ci_show=False, **plot_kwargs
          )
          timeline = np.unique(
              model.timeline.tolist() + model2.timeline.tolist() + [t]
          )
          predict1 = model.predict(timeline).loc[:t]
          predict2 = model2.predict(timeline).loc[:t]
          # positive
          ax.fill_between(
              timeline[timeline <= t],
              predict1,
              predict2,
              where=predict1 > predict2,
              step="post",
              facecolor="w",
              hatch="|",
              edgecolor="grey",
          )
  
          # negative
          ax.fill_between(
              timeline[timeline <= t],
              predict1,
              predict2,
              where=predict1 < predict2,
              step="post",
              hatch="-",
              facecolor="w",
              edgecolor="grey",
          )
  
          ax.text(
              text_position[0],
              text_position[1],
              "RMST(%s) -\n   RMST(%s)=%.3f"
              % (model._label, model2._label, rmst - rmst2),
          )  # dynamically pick this.
      else:
          rmst = restricted_mean_survival_time(model, t=t)
          sf_exp_at_limit = (
              model.predict(np.append(model.timeline, t))
              .sort_index()
              .loc[:t]
          )
          ax.fill_between(
              sf_exp_at_limit.index,
              sf_exp_at_limit.values,
              step="post",
              color=c,
              alpha=0.25,
          )
          ax.text(
              text_position[0], text_position[1], "RMST=%.3f" % rmst
          )  # dynamically pick this.
      ax.axvline(t, ls="--", color="k")
      ax.set_ylim(0, 1)
      return ax
  
imports: import warnings
  from typing import Union, Optional, Iterable
  from scipy import stats
  import pandas
  import numpy
  from lifelines.utils import coalesce, CensoringType, _group_event_table_by_intervals
label_desc: Use image node_id 5 for calling a global function with example usage: rmst_plot(model, model2, t, ax, text_position) and returns: ax