Skip to content

Commit

Permalink
hotfix box plotting to support latest pandas set_categories
Browse files Browse the repository at this point in the history
  • Loading branch information
gidden committed Nov 29, 2024
1 parent fed9410 commit af2022b
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions pyam/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
from pyam.run_control import run_control
from pyam.str import is_str
from pyam.timeseries import cross_threshold
from pyam.utils import (
IAMC_IDX,
META_IDX,
SORT_IDX,
YEAR_IDX,
to_list,
)
from pyam.utils import IAMC_IDX, META_IDX, SORT_IDX, YEAR_IDX, to_list

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -711,7 +705,7 @@ def box(df, y="value", x=None, by=None, legend=True, title=None, ax=None, **kwar
# TODO this only works if all categories are defined in run_control
palette = rc["color"][by]
df[by] = df[by].astype("category")
df[by].cat.set_categories(list(palette), inplace=True)
df[by] = df[by].cat.set_categories(list(palette))

Check warning on line 708 in pyam/plotting.py

View check run for this annotation

Codecov / codecov/patch

pyam/plotting.py#L708

Added line #L708 was not covered by tests
kwargs["palette"] = palette
else:
df.sort_values(by, inplace=True)
Expand Down

0 comments on commit af2022b

Please sign in to comment.