Metadata-Version: 2.4
Name: evaplot
Version: 0.1.0
Summary: An up-to-date and slimmed down library for opinionated plotting styles with seaborn and matplotlib
Author-email: Eva Maxfield Brown <evamaxfieldbrown@gmail.com>
License: MPLv2 License
Project-URL: Homepage, https://github.com/evamaxfield/evaplot
Project-URL: Bug Tracker, https://github.com/evamaxfield/evaplot/issues
Project-URL: Documentation, https://evamaxfield.github.io/opinionated-v2
Project-URL: User Support, https://github.com/evamaxfield/evaplot/issues
Classifier: Development Status :: 4 - Beta
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: colormaps>=0.5
Requires-Dist: fonttools>=4
Requires-Dist: matplotlib>=3
Requires-Dist: requests>=2
Requires-Dist: seaborn>=0.13
Provides-Extra: dev
Requires-Dist: jinja2>=3; extra == "dev"
Requires-Dist: prek>=0.3; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: typer>=0.12; extra == "dev"
Dynamic: license-file

# evaplot

An up-to-date and slimmed down library for opinionated plotting styles with seaborn and matplotlib.

## Installation

```bash
pip install evaplot
```

## Quick Start

```python
import evaplot
import seaborn as sns
import matplotlib.pyplot as plt

# Apply a style (downloads fonts on first use)
evaplot.set_style("evaplot_rc")

# Use seaborn/matplotlib as usual
fig, ax = plt.subplots()
sns.barplot(data=my_data, x="category", y="value", ax=ax)
plt.show()
```

## Styles

evaplot ships six styles, each using a different Google Font (downloaded automatically on first import):

| Style | Font |
|---|---|
| `evaplot_rc` | Roboto Condensed |
| `evaplot_fsc` | Fira Sans Condensed |
| `evaplot_j` | Jost |
| `evaplot_m` | Montserrat |
| `evaplot_sg` | Space Grotesk |
| `evaplot_tw` | Titillium Web |


### Gallery

#### `evaplot_rc` — Roboto Condensed

![evaplot_rc style example](docs/images/style_evaplot_rc.png)

<details>
<summary>Other styles</summary>


#### `evaplot_fsc` — Fira Sans Condensed

![evaplot_fsc style example](docs/images/style_evaplot_fsc.png)


#### `evaplot_j` — Jost

![evaplot_j style example](docs/images/style_evaplot_j.png)


#### `evaplot_m` — Montserrat

![evaplot_m style example](docs/images/style_evaplot_m.png)


#### `evaplot_sg` — Space Grotesk

![evaplot_sg style example](docs/images/style_evaplot_sg.png)


#### `evaplot_tw` — Titillium Web

![evaplot_tw style example](docs/images/style_evaplot_tw.png)


</details>

## Helper Functions

### `set_cat_palette`

Sets the categorical color palette based on the number of categories. Uses `dark2` for n ≤ 8 and `vivid` for larger sets. Returns the full palette as a list of hex strings you can reuse directly for annotations, custom patches, or other matplotlib elements.

```python
colors = evaplot.set_cat_palette(n=5)
# colors → ["#1b9e77", "#d95f02", ...]

# Annotate each bar with its hex color
for i, bar in enumerate(ax.patches):
    ax.text(
        bar.get_x() + bar.get_width() / 2,
        bar.get_height(),
        colors[i],
        ha="center", va="bottom",
        color=colors[i], fontsize=8,
    )
```

![set_cat_palette demo](docs/images/helper_set_cat_palette.png)

---

### `rotate_xticklabels`

Rotates x-axis tick labels to prevent overlap on busy categorical axes. Works on individual `Axes` objects and on every panel of a `FacetGrid` by iterating `g.axes.flat`.

```python
# single axes
evaplot.rotate_xticklabels(ax, rotation=45)

# every panel in a FacetGrid
for ax in g.axes.flat:
    evaplot.rotate_xticklabels(ax, rotation=45)
```

![rotate_xticklabels demo](docs/images/helper_rotate_xticklabels.png)

---

### `move_legend`

Moves a seaborn legend with sensible bottom-centered defaults.

```python
evaplot.move_legend(ax_or_facetgrid, bbox_to_anchor=(0.5, -0.15), loc="upper center", ncol=3)
```

![move_legend demo](docs/images/helper_move_legend.png)

---

### `adjust_layout`

Adjusts subplot spacing and applies `tight_layout` in one call. Pass `g.fig` for a seaborn FacetGrid, or omit `fig` to operate on the current figure.

```python
evaplot.adjust_layout(fig=fig, hspace=0.35, wspace=0.3)
```

![adjust_layout demo](docs/images/helper_adjust_layout.png)

---

### `set_facet_col_titles`

Simplifies FacetGrid column titles using a template string. By default strips the verbose `"col = value"` prefix.

```python
evaplot.set_facet_col_titles(g, "{col_name}")
```

<table>
<tr>
<td align="center"><b>Before</b></td>
<td align="center"><b>After</b></td>
</tr>
<tr>
<td><img src="docs/images/helper_set_facet_col_titles_before.png" alt="set_facet_col_titles before"></td>
<td><img src="docs/images/helper_set_facet_col_titles_after.png" alt="set_facet_col_titles after"></td>
</tr>
</table>

---

## API Reference

| Function | Description |
|---|---|
| `set_style(style, n)` | Apply an evaplot style and categorical palette |
| `set_cat_palette(n)` | Set categorical palette (`dark2` for n ≤ 8, `vivid` otherwise); returns hex color list |
| `rotate_xticklabels(ax, rotation, ha)` | Rotate x-axis tick labels |
| `move_legend(obj, bbox_to_anchor, loc, ncol, ...)` | Move a seaborn legend with opinionated defaults |
| `adjust_layout(fig, hspace, wspace, bottom, rect)` | Adjust subplot spacing and apply `tight_layout` |
| `set_facet_col_titles(g, template)` | Set FacetGrid column title template |
| `show_installed_fonts()` | List font families in evaplot's font cache |
| `update_matplotlib_fonts()` | Register all cached fonts with matplotlib |
| `download_googlefont(font, add_to_cache)` | Download a Google Font to the cache |

## Credits

evaplot builds on [opinionated](https://github.com/MNoichl/opinionated) by Maximilian Noichl.

> Noichl, M. (2023). Opinionated: Simple, Clean Stylesheets for Plotting with Matplotlib and Seaborn (Version 0.0.2.8) [Computer software]. https://doi.org/10.5281/zenodo.8329780

## License

MPLv2 License
