code: def format_date(x, _):
      try:
          # convert datetime64 to datetime, and use datetime's strftime:
          return r["date"][round(x)].item().strftime("%a")
      except IndexError:
          pass
  
file_path: matplotlib/galleries/examples/ticks/date_index_formatter.py
imports: import matplotlib.pyplot
  import numpy
  import matplotlib.cbook
  from matplotlib.dates import DateFormatter, DayLocator
  import matplotlib.lines
  from matplotlib.ticker import Formatter
label_desc: Use image node_id 1 for calling a global function with example usage: format_date(x, _) and returns: r