Plot
element_timeseries(ds, element='WTEQ', show_plot=True, ax=None, figsize=(10, 4))
Plot a time series for a given SNOTEL element across all stations in a dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Dataset returned by fetch_snotel(), with dimensions (time, station). |
required |
element
|
str
|
Element code to plot (e.g. "WTEQ", "SNWD", "TAVG"). Default is "WTEQ". |
'WTEQ'
|
show_plot
|
bool
|
If True, calls plt.show() after rendering. Set to False when embedding in a subplot or saving programmatically. Default is True. |
True
|
ax
|
Axes
|
Axes object to plot onto. If None, a new figure and axes are created. |
None
|
figsize
|
tuple
|
Figure size as (width, height) in inches. Only used when ax is None. Default is (10, 4). |
(10, 4)
|
Returns:
| Type | Description |
|---|---|
Axes
|
The axes object, for further customization or embedding in subplots. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If ds is not an xarray.Dataset. |
ValueError
|
If the element code is not found in ds. |
Examples:
>>> ds = sp.fetch_snotel(stations=["602:CO:SNTL"], elements=["WTEQ"],
... start_date="2022-10-01", end_date="2023-03-31")
>>> ax = sp.plot.element_timeseries(ds, element="WTEQ")
>>> # Embed in a subplot without auto-showing
>>> fig, axes = plt.subplots(2, 1, figsize=(10, 8))
>>> sp.plot.element_timeseries(ds, element="WTEQ", show_plot=False, ax=axes[0])
>>> sp.plot.element_timeseries(ds, element="SNWD", show_plot=False, ax=axes[1])
>>> plt.tight_layout()
>>> plt.show()