datenumformatter#

datenumformatter(ax=None, start_date=None, dateformat=None, interval=None, start=None, end=None, rotation=None)[source]#

Format a numeric x-axis to use dates.

See also sc.dateformatter(), which is intended for use when the axis already has date data.

Parameters:
  • ax (axes) – if supplied, use these axes instead of the current one

  • start_date (str/date) – the start day, either as a string or date object (not needed if x-axis already uses dates)

  • dateformat (str) – the date format (default '%Y-%b-%d'; not needed if x-axis already uses dates)

  • interval (int) – if supplied, the interval between ticks (not needed if x-axis already uses dates)

  • start (str/int) – if supplied, the lower limit of the axis

  • end (str/int) – if supplied, the upper limit of the axis

  • rotation (float) – rotation of the labels, in degrees

Examples:

# Automatically configure a non-date axis with default options
plt.plot(np.arange(365), np.random.rand(365))
sc.datenumformatter(start_date='2021-01-01')

# Manually configure
fig,ax = plt.subplots()
ax.plot(np.arange(60), np.random.random(60))
formatter = sc.datenumformatter(start_date='2020-04-04', interval=7, start='2020-05-01', end=50, dateformat='%m-%d', ax=ax)
New in version 1.2.0.
New in version 1.2.2: “rotation” argument; renamed “start_day” to “start_date”
New in version 1.3.3: renamed from sc.dateformatter() to sc.datenumformatter()