Skip to content

feat!: compatibility with matplotlib 3.11 - #128

Open
miloth wants to merge 19 commits into
catppuccin:mainfrom
miloth:main
Open

feat!: compatibility with matplotlib 3.11#128
miloth wants to merge 19 commits into
catppuccin:mainfrom
miloth:main

Conversation

@miloth

@miloth miloth commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Matplotlib 3.11 reworked the style module, changing the APIs that were used here. This aims at solving that and a bit more:

  • Vendor the styles using the docs guidelines:
    • Style files generated in the module root, so they can be imported as "catppuccin.<flavor>".
    • Removed legacy vendoring.
  • Removed all the public functions in the catppuccin.extras.matplotlib module. Their functionality can be replicated with a one liner of Matplotlib's APIs. All the examples now use these one liners.
  • Removed the assets and their generation. The users can run the example themselves to generate them. They were ~2 MB images, not used anywhere. I think these could pollute the git size if left there.
  • Helper file for the codegen moved outside of the module in the repo root, so it is not shipped to Pypi.
  • Update tests to cover the cmaps as well.
  • Updated cmaps to be colored and not mono.
  • Updated palette from upstream.
  • Updated dev dependencies.

@backwardspy

Copy link
Copy Markdown
Member

@brambozz any chance you could give this a review? you know it better than i do i think :)

@brambozz

Copy link
Copy Markdown
Collaborator

Yes, I will try to have a look this week!

@brambozz

Copy link
Copy Markdown
Collaborator

@miloth Thanks for the comprehensive PR, overall looks good to me! Especially really like the addition of a default (non-mono) colormap! That makes a lot of sense, and is something I could have used for a while.

Only thing I am not a fan of is the removal of the get_colormap_from_list function, in lieu of the matplotlib one-liner. This is a function I actually use frequently, to e.g. easily define a diverging colormap. While I understand that this is maybe not a functionality unique to catppuccin, I do think there is a difference in ease of use/clarity between these two:

Original:

from catppuccin.extras.matplotlib import get_colormap_from_list

cmap = get_colormap_from_list(
       catppuccin.PALETTE.frappe.identifier,
       ["red", "peach", "yellow", "green"],
)

PR suggestion:

from matplotlib.colors import LinearSegmentedColormap

cmap = LinearSegmentedColormap.from_list(
    "my_custom_palette",
    [
        getattr(catppuccin.PALETTE.frappe.colors, color_name).hex
        for color_name in ["red", "peach", "yellow", "green"]
    ],
)

@backwardspy:I think it would be good if you have a quick look too, as there are some changes to files I did not write (e.g. build.py). But looks good to me! One specific thing I spotted:

  • The PR upgrades minimum versions of python and matplotlib to 3.11. Seems fine to me, but maybe this is something you have thoughts about. The PR also goes from 2.5 to 3.0, so would amount to a new release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants