geodata.plot.time_series#
- geodata.plot.time_series(ds: xarray.DataArray, lat_slice: CoordinateType | None = None, lon_slice: CoordinateType | None = None, agg_slice: bool = True, agg_slice_method: ReductionType = 'mean', coord_dict: dict[str, CoordinateType] | None = None, time_factor: float = 1.0, agg_time_method: ReductionType = 'mean', figsize: tuple[float, float] = (10.0, 5.0), ds_name: str | None = None, loc_name: str | None = None, title: str | None = None, title_size: float = 12.0, grid: bool = True, legend: bool = True, return_fig: bool = False, **kwargs) matplotlib.pyplot.Figure | None#
Take in the xarray.DataArray, slice of latitude or longitude, plot the time series. When users give lat or lon slices, the values can be mean/sum aggregated. Users can also provide a dictionary of name-coordinate pairs instead of lat and lon input. By default, the method shows the time series’ aggregated mean.
- Parameters:
ds (xr.DataArray) – The target xarray.DataArray object.
lat_slice (tuple) – The slice of latitude values.
lon_slice (tuple) – The slice of longitude values
agg_slice (bool) – Whether the program plot the aggregate values from the slices
agg_slice_method (str) – Reduction method for aggregating the spatial slices. This can be either “mean” or “sum”.
coord_dict (dict) – The (Name, Coordinate) pair of different locations; An example: {‘Beijing’: (40, 116.25), ‘Shanghai’: (31, 121.25)}
time_factor (float) – The factor to aggregate the value of dataArray on An example: for daily mean on hourly data, time_factor = 24
agg_time_method (str) – Reduction method for time dimension. This can be either “mean” or “sum”.
figsize (tuple) – The size of the plot
ds_name (str) – Name of the DataArray to be shown on title
loc_name (str) – Location of the place to be shown on title
title (str) – The title of the result plot
title_size (float) – The size of the title of the result plolt
grid (bool) – Whether to add grid lines to the plot, True by default
legend (bool) – Add legend to the plot if multiple locations are provided, True by default
return_fig (bool) – Whether to return the figure or not. True by default
**kwargs – Other keyword arguments for xarray.DataArray.plot()
- Returns:
The figure object if return_fig is True.
- Return type:
Optional[plt.Figure]
- Raises:
NotImplementedError – If the reduction method is not supported.