backstrip adds color-coordinated fill behind matplotlib boxplots.
Project description
backstrip adds color-coordinated fill behind matplotlib boxplots
- Free software: MIT license
- Repository: https://github.com/mmore500/backstrip
Install
python3 -m pip install backstrip
Example Usage
from backstrip import backstrip
from matplotlib import pyplot as plt
import seaborn as sns
titanic = sns.load_dataset("titanic")
ax = sns.boxplot(data=titanic, x="class", y="age", hue="alive")
backstrip(ax)
plt.show()
API
def backstrip(
ax: plt.Axes,
alpha: float = 0.5,
hue: typing.Optional[typing.Iterable[str]] = None,
hatch: typing.Optional[typing.Iterable[str]] = None,
hatch_color: typing.Union[str, typing.Iterable[str]] = "white",
orient: str = "v",
**kwargs,
) -> None:
"""
Draws background strips behind boxplot patches on a matplotlib Axes
object to enhance the visual identifiability of hue-keyed groups.
This function iterates over PathPatch objects (representing boxes) within a
matplotlib Axes, and draws semi-transparent rectangles (strips) in the
background.
These strips can be customized in color (`hue`), pattern (`hatch`), and
orientation (`orient`).
Parameters
----------
ax : plt.Axes
The matplotlib Axes object on which to draw the backstrips.
alpha : float, default 0.5
The opacity level of the backstrips.
hue : Union[None, str, Iterable[str]], optional
The color(s) for the backstrips.
Can be a single color or a sequence of colors. If `None`, the colors of
the box objects in the Axes are matched.
hatch : Union[None, str, Iterable[str]], default None
The hatch pattern(s) for the backstrips.
Can be a single pattern or a sequence of patterns. If `None`, no
hatch patterns are applied.
hatch_color : Union[str, Iterable[str]], default 'white'
The color of hatch patterns, if applied.
orient : str, default 'v'
The orientation of the backstrips. Can be 'v' for vertical or 'h' for
horizontal.
kwargs : dict
Additional keyword arguments to pass to the `Rectangle` patches.
Returns
-------
None
"""
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
backstrip-0.1.0.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for backstrip-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01f126b579f960ff2219c45e31989fb37ab75ffb31075f4c2cf807f05c1c658e |
|
MD5 | d45e29d4b4d506aebda6211bc42d877c |
|
BLAKE2b-256 | 10991dd792e111bcaf44da59b4f6766146437b9fb38a6d215f441b02958e4ecb |