Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: abatilo/actions-poetry@v3
- run: poetry install --all-extras
- run: poetry run ruff check
- run: poetry run ruff format --check --diff
- run: poetry run mypy .
- uses: astral-sh/setup-uv@v5
with:
version: 0.6.3
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: "uv.lock"
- run: uv sync --all-extras
- run: uv run ruff check
- run: uv run ruff format --check --diff
- run: uv run mypy .
12 changes: 8 additions & 4 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: abatilo/actions-poetry@v3
- run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
- run: poetry publish --build
python-version-file: "pyproject.toml"
- uses: astral-sh/setup-uv@v5
with:
version: 0.6.3
enable-cache: true
cache-dependency-glob: "uv.lock"
- run: uv build
- run: uv publish
20 changes: 12 additions & 8 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
on:
push:
paths:
- '**.py'
- 'poetry.toml'
- 'poetry.lock'
- 'pyproject.toml'
- "**.py"
- "pyproject.toml"
- "uv.lock"

name: test

Expand All @@ -13,13 +12,18 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: abatilo/actions-poetry@v3
- run: poetry install --all-extras
- run: poetry run pytest --cov catppuccin
- uses: astral-sh/setup-uv@v5
with:
version: 0.6.3
python-version: "${{ matrix.python-version }}"
enable-cache: true
cache-dependency-glob: "uv.lock"
- run: uv sync --all-extras
- run: uv run pytest --cov catppuccin
150 changes: 90 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ get_style_by_name("catppuccin-frappe")

The following style names are available:

- `catppuccin-latte`
- `catppuccin-frappe`
- `catppuccin-macchiato`
- `catppuccin-mocha`
- `catppuccin-latte`
- `catppuccin-frappe`
- `catppuccin-macchiato`
- `catppuccin-mocha`

They can also be accessed by directly importing them:

Expand Down Expand Up @@ -137,53 +137,59 @@ The library tries to register styles and colormaps if `matplotlib` is installed.
See the examples below for some use cases:

1. Load a style, using `mpl.style.use`
```python
import catppuccin
import matplotlib as mpl
import matplotlib.pyplot as plt

mpl.style.use(catppuccin.PALETTE.mocha.identifier)
plt.plot([0,1,2,3], [1,2,3,4])
plt.show()
```

```python
import catppuccin
import matplotlib as mpl
import matplotlib.pyplot as plt

mpl.style.use(catppuccin.PALETTE.mocha.identifier)
plt.plot([0,1,2,3], [1,2,3,4])
plt.show()
```

1. Mix it with different stylesheets!
```python
import catppuccin
import matplotlib as mpl
import matplotlib.pyplot as plt

mpl.style.use(["ggplot", catppuccin.PALETTE.mocha.identifier])
plt.plot([0,1,2,3], [1,2,3,4])
plt.show()
```

```python
import catppuccin
import matplotlib as mpl
import matplotlib.pyplot as plt

mpl.style.use(["ggplot", catppuccin.PALETTE.mocha.identifier])
plt.plot([0,1,2,3], [1,2,3,4])
plt.show()
```

1. Load individual colors
```python
import matplotlib.pyplot as plt
import catppuccin
from catppuccin.extras.matplotlib import load_color

color = load_color(catppuccin.PALETTE.latte.identifier, "peach")
plt.plot([0,1,2,3], [1,2,3,4], color=color)
plt.show()
```

```python
import matplotlib.pyplot as plt
import catppuccin
from catppuccin.extras.matplotlib import load_color

color = load_color(catppuccin.PALETTE.latte.identifier, "peach")
plt.plot([0,1,2,3], [1,2,3,4], color=color)
plt.show()
```

1. Define custom colormaps
```python
import matplotlib.pyplot as plt
import numpy as np
import catppuccin
from catppuccin.extras.matplotlib import get_colormap_from_list

cmap = get_colormap_from_list(
catppuccin.PALETTE.frappe.identifier,
["red", "peach", "yellow", "green"],
)
rng = np.random.default_rng()
data = rng.integers(2, size=(30, 30))
```python
import matplotlib.pyplot as plt
import numpy as np
import catppuccin
from catppuccin.extras.matplotlib import get_colormap_from_list

plt.imshow(data, cmap=cmap)
plt.show()
```
cmap = get_colormap_from_list(
catppuccin.PALETTE.frappe.identifier,
["red", "peach", "yellow", "green"],
)
rng = np.random.default_rng()
data = rng.integers(2, size=(30, 30))

plt.imshow(data, cmap=cmap)
plt.show()
```

## Contribution

Expand All @@ -193,14 +199,14 @@ first!

### Development

This project is maintained with [Poetry](https://python-poetry.org). If you
don't have Poetry yet, you can install it using the [installation
instructions](https://python-poetry.org/docs/#installation).
This project is maintained with [uv](https://docs.astral.sh/uv/). If you
don't have uv yet, you can install it using the [installation
instructions](https://docs.astral.sh/uv/getting-started/installation/).

Install the project's dependencies including extras:

```bash
poetry install --all-extras
uv sync --all-extras
```

#### Codegen
Expand All @@ -210,27 +216,51 @@ poetry install --all-extras
To update after downloading a new palette JSON file:

```console
poetry run python build.py
uv run build.py
```

Formatting this file is done manually as with any other file, see [`Code Standards`](#code-standards) below.

#### Code Standards

Before committing changes, it is recommended to run the following tools to
ensure consistency in the codebase.
All of the tools listed in this section are automatically installed by uv as
part of the `dev` dependency group.

```bash
ruff format
ruff check
mypy .
pytest --cov catppuccin
##### Unit Tests

Tests are run with [`pytest`](https://docs.pytest.org/en/stable/).

To run tests and display coverage:

```console
$ pytest --cov catppuccin
```

These tools are all installed as part of the `dev` dependency group with
Poetry. You can use `poetry shell` to automatically put these tools in your
path.
##### Type Checking

Type checking is performed by [`mypy`](https://www.mypy-lang.org/).

To run type checks:

```console
$ mypy .
```

##### Lints and Formatting

Code linting and formatting is done by [`ruff`](https://docs.astral.sh/ruff/).

To lint the code:

```console
$ ruff check
```

To format the code:

```console
$ ruff format
```

## 💝 Thanks to

Expand Down
5 changes: 4 additions & 1 deletion catppuccin/extras/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@

from dataclasses import asdict
from pathlib import Path
from typing import Iterable, cast
from typing import TYPE_CHECKING, cast

import matplotlib as mpl
import matplotlib.colors
import matplotlib.style

from catppuccin.palette import PALETTE

if TYPE_CHECKING:
from collections.abc import Iterable

CATPPUCCIN_STYLE_DIRECTORY = Path(__file__).parent / "matplotlib_styles"
DEFAULT_COLORMAP_COLORS = ("base", "blue")

Expand Down
2 changes: 1 addition & 1 deletion catppuccin/extras/matplotlib_styles/frappe.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ grid.color: 414559

# Boxplots: Overlay 0
boxplot.flierprops.color: 737994
boxplot.flierprops.markerfacecolor: 737994
boxplot.flierprops.markerfacecolor: 737994
boxplot.flierprops.markeredgecolor: 737994
boxplot.boxprops.color: 737994
boxplot.whiskerprops.color: 737994
Expand Down
2 changes: 1 addition & 1 deletion catppuccin/extras/matplotlib_styles/latte.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ grid.color: ccd0da

# Boxplots: Overlay 0
boxplot.flierprops.color: 9ca0b0
boxplot.flierprops.markerfacecolor: 9ca0b0
boxplot.flierprops.markerfacecolor: 9ca0b0
boxplot.flierprops.markeredgecolor: 9ca0b0
boxplot.boxprops.color: 9ca0b0
boxplot.whiskerprops.color: 9ca0b0
Expand Down
2 changes: 1 addition & 1 deletion catppuccin/extras/matplotlib_styles/macchiato.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ grid.color: 363a4f

# Boxplots: Overlay 0
boxplot.flierprops.color: 6e738d
boxplot.flierprops.markerfacecolor: 6e738d
boxplot.flierprops.markerfacecolor: 6e738d
boxplot.flierprops.markeredgecolor: 6e738d
boxplot.boxprops.color: 6e738d
boxplot.whiskerprops.color: 6e738d
Expand Down
2 changes: 1 addition & 1 deletion catppuccin/extras/matplotlib_styles/mocha.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ grid.color: 313244

# Boxplots: Overlay 0
boxplot.flierprops.color: 6c7086
boxplot.flierprops.markerfacecolor: 6c7086
boxplot.flierprops.markerfacecolor: 6c7086
boxplot.flierprops.markeredgecolor: 6c7086
boxplot.boxprops.color: 6c7086
boxplot.whiskerprops.color: 6c7086
Expand Down
2 changes: 1 addition & 1 deletion catppuccin/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Dataclass definitions for the Catppuccin palette data structure."""

from collections.abc import Iterator
from dataclasses import dataclass
from typing import Iterator


@dataclass(frozen=True)
Expand Down
2 changes: 1 addition & 1 deletion example_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def example_plot() -> plt.Figure: # type: ignore [name-defined]

fig = plt.figure()
for idx, phase in enumerate(phases):
plt.plot(x, np.sin(2 * np.pi * x + phase), label=f"Color {idx+1}")
plt.plot(x, np.sin(2 * np.pi * x + phase), label=f"Color {idx + 1}")
plt.grid()
plt.legend()

Expand Down
Loading