code: def format_dateaxis(subplot, freq, index):
      """
      Pretty-formats the date axis (x-axis).
  
      Major and minor ticks are automatically set for the frequency of the
      current underlying series.  As the dynamic mode is activated by
      default, changing the limits of the x axis will intelligently change
      the positions of the ticks.
      """
  
      # handle index specific formatting
      # Note: DatetimeIndex does not use this
      # interface. DatetimeIndex uses matplotlib.date directly
      if isinstance(index, ABCPeriodIndex):
          majlocator = TimeSeries_DateLocator(
              freq,
              dynamic_mode=True,
              minor_locator=False,
              plot_obj=subplot,
          )
          minlocator = TimeSeries_DateLocator(
              freq,
              dynamic_mode=True,
              minor_locator=True,
              plot_obj=subplot,
          )
          subplot.xaxis.set_major_locator(majlocator)
          subplot.xaxis.set_minor_locator(minlocator)
  
          majformatter = TimeSeries_DateFormatter(
              freq,
              dynamic_mode=True,
              minor_locator=False,
              plot_obj=subplot,
          )
          minformatter = TimeSeries_DateFormatter(
              freq,
              dynamic_mode=True,
              minor_locator=True,
              plot_obj=subplot,
          )
          subplot.xaxis.set_major_formatter(majformatter)
          subplot.xaxis.set_minor_formatter(minformatter)
  
          # x and y coord info
          subplot.format_coord = functools.partial(_format_coord, freq)
  
      elif isinstance(index, ABCTimedeltaIndex):
          subplot.xaxis.set_major_formatter(
              TimeSeries_TimedeltaFormatter()
          )
      else:
          raise TypeError("index type not supported")
  
      pylab.draw_if_interactive()
  
imports: import functools
  from matplotlib import pylab
  import numpy
  from pandas._libs.tslibs.frequencies import FreqGroup, get_base_alias, get_freq, is_subperiod, is_superperiod
  from pandas._libs.tslibs.period import Period
  import pandas.compat
  from pandas.core.dtypes.generic import ABCDatetimeIndex, ABCPeriodIndex, ABCTimedeltaIndex
  from pandas.io.formats.printing import pprint_thing
  from pandas.plotting._converter import TimeSeries_DateFormatter, TimeSeries_DateLocator, TimeSeries_TimedeltaFormatter
  import pandas.tseries.frequencies
  from pandas.tseries.offsets import DateOffset
label_desc: Use image node_id 15 for calling a global function with example usage: format_dateaxis(subplot, freq, index) without return types