Skip to content

how to best set lim? // allow string in convert? #178

@mathause

Description

@mathause

✨ Feature Request

Should/ could allow passing a string to convert (of the NetCDFTimeConverter) be beneficial?

Motivation

I want to set the xlim of a nc-time axis. Is there a more convinent way than to pass cftime._cftime.datetime?

It seems I need to do:

import numpy as np
import matplotlib.pyplot as plt
import xarray as xr

data = np.random.randn(100)
time = xr.date_range("2000", "2100", freq="A", calendar="noleap")
da = xr.DataArray(data, coords={"time": time})

f, ax = plt.subplots()

da.plot(ax=ax)
ax.set_xlim(None, da.time.sel(time="2050").item())

It would be nice if we could pass a string - similar as we do with sel in xarray, e.g.:

ax.set_xlim(None, "2050")

Additional context

Click to expand this section...
Please add additional verbose information in this section e.g., references, screenshots, listings etc

Metadata

Metadata

Assignees

No one assigned

    Labels

    New: FeatureHighlight a new community raised "feature request" issue

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions