Skip to content

🚀 Release: CFTime Support and Integration

Choose a tag to compare

@cvanelteren cvanelteren released this 08 Oct 02:34
· 4179 commits to main since this release

Highlights

CFTime Axis Support:
We’ve added robust support for CFTime objects throughout ultraplot. This enables accurate plotting and formatting of time axes using non-standard calendars (e.g., noleap, gregorian, standard), which are common in climate and geoscience datasets.

Automatic Formatter and Locator Selection:
ultraplot now automatically detects CFTime axes and applies the appropriate formatters and locators, ensuring correct tick placement and labeling for all supported calendar types.

Seamless Integration with xarray:
These features are designed for direct use with xarray datasets and dataarrays. When plotting data with CFTime indexes, ultraplot will handle all time axis formatting and tick generation automatically—no manual configuration required.


Intended Use

This release is aimed at users working with climate, weather, and geoscience data, where time coordinates may use non-standard calendars. The new CFTime functionality ensures that plots generated from xarray and other scientific libraries display time axes correctly, regardless of calendar type.


Example Usage

import xarray as xr
import numpy as np
import cftime
import ultraplot as uplt

# Create a sample xarray DataArray with CFTime index
times = [cftime.DatetimeNoLeap(2001, 1, i+1) for i in range(10)]
data = xr.DataArray(np.random.rand(10), coords=[times], dims=["time"])

fig, ax = uplt.subplots()
data.plot(ax=ax)

# CFTime axes are automatically formatted and labeled
ax.set_title("CFTime-aware plotting with ultraplot")
uplt.show()

Migration and Compatibility

  • No changes are required for existing code using standard datetime axes.
  • For datasets with CFTime indexes (e.g., from xarray), simply plot as usual—ultraplot will handle the rest.

We welcome feedback and bug reports as you explore these new capabilities!

What's Changed

New Contributors

  • @Copilot made their first contribution in #325

Full Changelog: v1.60.2...v1.61.0

Note: v1.61.0 is yanked from pypi as it contained a debug statement. This merely removes the debug.