Skip to content

Marsilea-viz/legendkit

Repository files navigation

Documentation Status pypi version

When you want to create or adjust the legend in matplotlib, things can get dirty. Legendkit may solve your headache.

Features

  • Easy title placement and alignment
  • Easy colorbar with shape
  • Layout for multiple legends and colorbar*

Installation

pip install legendkit

Quickstart

import numpy as np
import matplotlib.pyplot as plt
from legendkit import cat_legend, colorbar, vstack

fig, ax = plt.subplots()
data = np.random.rand(10, 10)
mappable = ax.pcolormesh(data, cmap="RdBu")

# Categorical legend
leg = cat_legend(ax, colors=["#e63946", "#457b9d", "#2a9d8f"],
                 labels=["Group A", "Group B", "Group C"], title="Groups")

# Colorbar placed outside axes
colorbar(mappable, ax=ax, title="Value")
plt.show()

About

Legend made easy for matplotlib

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages