API reference

This page provides a reference for the API of nc-time-axis.

CalendarDateTime

For historical reasons, nc-time-axis defines a CalendarDateTime class which encapsulates a cftime.datetime object and its calendar type. This is no longer needed, and will be removed in nc-time-axis version 1.5, but we document it here for now.

CalendarDateTime(datetime, calendar)

Container for a cftime.datetime object and calendar.

Formatters

The AutoCFTimeFormatter is what is used by default when plotting cftime.datetime axis; it will automatically pick a date label format depending on the axis range. If you would like more control over the format of the date labels you may use the CFTimeFormatter class.

AutoCFTimeFormatter(locator, calendar[, ...])

Automatic formatter for cftime.datetime data.

CFTimeFormatter(format, calendar)

A formatter for explicitly setting the format of a cftime.datetime axis.

Locators

The NetCDFTimeDateLocator is what is used by default to set the tick locations depending on the range of the axis. For finer-grained control over the tick locations, use matplotlib’s matplotlib.axes.Axes.set_xticks() or matplotlib.axes.Axes.set_yticks() methods to set the tick locations explicitly.

NetCDFTimeDateLocator(max_n_ticks, calendar)

Determines tick locations when plotting cftime.datetime data.

Converters

Internally, nc-time-axis must convert times to numerical values so that matplotlib can plot them on axes. The NetCDFTimeConverter is used for this purpose.

NetCDFTimeConverter(*[, interval_multiples])

Converter for cftime.datetime data.