code: def create_event_study_tear_sheet(
      factor_data,
      returns,
      avgretplot=(5, 15),
      rate_of_ret=True,
      n_bars=50,
  ):
      """
      Creates an event study tear sheet for analysis of a specific event.
  
      Parameters
      ----------
      factor_data : pd.DataFrame - MultiIndex
          A MultiIndex DataFrame indexed by date (level 0) and asset (level 1),
          containing the values for a single event, forward returns for each
          period, the factor quantile/bin that factor value belongs to, and
          (optionally) the group the asset belongs to.
      returns : pd.DataFrame, required only if 'avgretplot' is provided
          A DataFrame indexed by date with assets in the columns containing daily
          returns.
          - See full explanation in utils.get_clean_factor_and_forward_returns
      avgretplot: tuple (int, int) - (before, after), optional
          If not None, plot event style average cumulative returns within a
          window (pre and post event).
      rate_of_ret : bool, optional
          Display rate of return instead of simple return in 'Mean Period Wise
          Return By Factor Quantile' and 'Period Wise Return By Factor Quantile'
          plots
      n_bars : int, optional
          Number of bars in event distribution plot
      """
  
      long_short = False
  
      plotting.plot_quantile_statistics_table(factor_data)
  
      gf = GridFigure(rows=1, cols=1)
      plotting.plot_events_distribution(
          events=factor_data["factor"],
          num_bars=n_bars,
          ax=gf.next_row(),
      )
      plt.show()
      gf.close()
  
      if returns is not None and avgretplot is not None:
          create_event_returns_tear_sheet(
              factor_data=factor_data,
              returns=returns,
              avgretplot=avgretplot,
              long_short=long_short,
              group_neutral=False,
              std_bar=True,
              by_group=False,
          )
  
      factor_returns = perf.factor_returns(
          factor_data, demeaned=False, equal_weight=True
      )
  
      mean_quant_ret, std_quantile = perf.mean_return_by_quantile(
          factor_data, by_group=False, demeaned=long_short
      )
      if rate_of_ret:
          mean_quant_ret = mean_quant_ret.apply(
              utils.rate_of_return,
              axis=0,
              base_period=mean_quant_ret.columns[0],
          )
  
      (
          mean_quant_ret_bydate,
          std_quant_daily,
      ) = perf.mean_return_by_quantile(
          factor_data, by_date=True, by_group=False, demeaned=long_short
      )
      if rate_of_ret:
          mean_quant_ret_bydate = mean_quant_ret_bydate.apply(
              utils.rate_of_return,
              axis=0,
              base_period=mean_quant_ret_bydate.columns[0],
          )
  
      fr_cols = len(factor_returns.columns)
      vertical_sections = 2 + fr_cols * 1
      gf = GridFigure(rows=vertical_sections + 1, cols=1)
  
      plotting.plot_quantile_returns_bar(
          mean_quant_ret,
          by_group=False,
          ylim_percentiles=None,
          ax=gf.next_row(),
      )
  
      plotting.plot_quantile_returns_violin(
          mean_quant_ret_bydate,
          ylim_percentiles=(1, 99),
          ax=gf.next_row(),
      )
  
      trading_calendar = factor_data.index.levels[0].freq
      if trading_calendar is None:
          trading_calendar = pd.tseries.offsets.BDay()
          warnings.warn(
              "'freq' not set in factor_data index: assuming business day",
              UserWarning,
          )
  
      plt.show()
      gf.close()
  
file_path: alphalens/alphalens/tears.py
imports: import matplotlib.gridspec
  import matplotlib.pyplot
  import pandas
  import warnings
  from .None import plotting
  from .None import performance
  from .None import utils
label_desc: Use image node_id 7 for calling a global function with example usage: create_event_study_tear_sheet(factor_data, returns, avgretplot, rate_of_ret, n_bars) without return types