Skip to content

plot_years with a size 1 "show" dimension #63

@jucordero

Description

@jucordero

matplotlib complains when trying to generate a plot_years plot on a DataArray with a size-1 named dimension and using it as the "show" parameter.

To reproduce the error:

from agrifoodpy.food.food import FoodElementSheet
import xarray as xr
import numpy as np

da_1 = xr.DataArray(np.random.rand(5,1),
                        coords=[('Year', [2010, 2011, 2012, 2013, 2014]),
                                ('Region', ['A'])],
                        dims=['Year', 'Region'])
fbs_1 = FoodElementSheet(da_1)

fbs_1.plot_years(show="Region")

I tried using da.squeeze() to remove size-1 named dimension and it does seems to fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions