Skip to content

Commit 580dabc

Browse files
authored
feat: added matplotlib support (#36)
1 parent 12fcd21 commit 580dabc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1188
-81
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,60 @@ and ensuring `catppuccin[pygments]` is installed in the same environment will
131131
give you Catppuccin Mocha syntax highlighting in the REPL. See [here](https://github.com/backwardspy/dots/blob/f6991570d6691212e27e266517656192f910ccbf/dot_config/ipython/profile_default/ipython_config.py)
132132
for an example of a more complete configuration.
133133

134+
## Matplotlib
135+
136+
The library tries to register styles and colormaps if `matplotlib` is installed.
137+
See the examples below for some use cases:
138+
139+
1. Load a style, using `mpl.style.use`
140+
```python
141+
import catppuccin
142+
import matplotlib as mpl
143+
import matplotlib.pyplot as plt
144+
145+
mpl.style.use(catppuccin.PALETTE.mocha.identifier)
146+
plt.plot([0,1,2,3], [1,2,3,4])
147+
plt.show()
148+
```
149+
1. Mix it with different stylesheets!
150+
```python
151+
import catppuccin
152+
import matplotlib as mpl
153+
import matplotlib.pyplot as plt
154+
155+
mpl.style.use(["ggplot", catppuccin.PALETTE.mocha.identifier])
156+
plt.plot([0,1,2,3], [1,2,3,4])
157+
plt.show()
158+
```
159+
1. Load individual colors
160+
```python
161+
import matplotlib.pyplot as plt
162+
import catppuccin
163+
from catppuccin.extras.matplotlib import load_color
164+
165+
color = load_color(catppuccin.PALETTE.latte.identifier, "peach")
166+
plt.plot([0,1,2,3], [1,2,3,4], color=color)
167+
plt.show()
168+
```
169+
1. Define custom colormaps
170+
```python
171+
import matplotlib.pyplot as plt
172+
import numpy as np
173+
import catppuccin
174+
from catppuccin.extras.matplotlib import get_colormap_from_list
175+
176+
cmap = get_colormap_from_list(
177+
catppuccin.PALETTE.frappe.identifier,
178+
["red", "peach", "yellow", "green"],
179+
)
180+
rng = np.random.default_rng()
181+
data = rng.integers(2, size=(30, 30))
182+
183+
plt.imshow(data, cmap=cmap)
184+
plt.show()
185+
```
186+
187+
134188
## Contribution
135189

136190
If you are looking to contribute, please read through our

β€Žassets/frappe/bar.pngβ€Ž

18.8 KB
Loading

β€Žassets/frappe/boxplot.pngβ€Ž

21.3 KB
Loading

β€Žassets/frappe/imshow.pngβ€Ž

15.4 KB
Loading

β€Žassets/frappe/palette.pngβ€Ž

155 KB
Loading

β€Žassets/frappe/patches.pngβ€Ž

73.6 KB
Loading

β€Žassets/frappe/plot.pngβ€Ž

161 KB
Loading

β€Žassets/frappe/scatter.pngβ€Ž

55.3 KB
Loading

β€Žassets/latte/bar.pngβ€Ž

18.6 KB
Loading

β€Žassets/latte/boxplot.pngβ€Ž

21.3 KB
Loading

0 commit comments

Comments
Β (0)