Package: backstrip
backstripadds color-coordinated fill behind matplotlib boxplotsFree software: MIT licenseRepository:https://github.com/mmore500/backstripInstallpython3 -m pip install backstripExample Usagefrombackstripimportbackstripfrommatplotlibimportpyplotaspltimportseabornassnstitanic=sns.load_dataset("titanic")ax=sns.boxplot(data=titanic,x="age",y="class",hue="alive",orient="h")backstrip(ax,hatch=["oo","xx"],orient="h")plt.show()frombackstripimportbackplotfrommatplotlibimportpyplotaspltimportseabornassnsg=backplot(data=sns.load_dataset("titanic"),x="class",y="age",hue="alive",col="who",style="alone",# hatches by this column)plt.show()APIbackstrip: direct, axes-level interfacedefbackstrip(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:typing.Literal["v","h"]="v",**kwargs,)->None:"""Draws background strips behind boxplot patches on a matplotlib Axesobject to enhance the visual identifiability of hue-keyed groups.This function iterates over PathPatch objects (representing boxes) within amatplotlib Axes, and draws semi-transparent rectangles (strips) in thebackground.These strips can be customized in color (`hue`), pattern (`hatch`), andorientation (`orient`).Parameters----------ax : plt.AxesThe matplotlib Axes object on which to draw the backstrips.alpha : float, default 0.5The opacity level of the backstrips.hue : Union[None, str, Iterable[str]], optionalThe color(s) for the backstrips.Can be a single color or a sequence of colors. If `None`, the colors ofthe box objects in the Axes are matched.hatch : Union[None, str, Iterable[str]], default NoneThe hatch pattern(s) for the backstrips.Can be a single pattern or a sequence of patterns. If `None`, nohatch patterns are applied.hatch_color : Union[str, Iterable[str]], default 'white'The color of hatch patterns, if applied.orient : Literal['v', 'h'], default 'v'The orientation of the backstrips.Should match orientation of boxplot. Can be 'v' for vertical or 'h' forhorizontal.kwargs : dictAdditional keyword arguments to pass to the `Rectangle` patches.Returns-------None"""backplot: tidy-data, figure-level interfacedefbackplot(data:pd.DataFrame,x:typing.Optional[str]=None,y:typing.Optional[str]=None,hue:typing.Optional[str]=None,style:typing.Optional[str]=None,col:typing.Optional[str]=None,row:typing.Optional[str]=None,order:typing.Optional[typing.Sequence[str]]=None,hue_order:typing.Optional[typing.Sequence[str]]=None,style_order:typing.Optional[typing.Sequence[str]]=None,hatches:typing.Optional[typing.Sequence[str]]=None,orient:typing.Literal["v","h"]="v",palette:typing.Optional[typing.Union[str,typing.Sequence[str]]]=None,backstrip_kws:dict=frozendict(),legend_width_inches:float=1.5,legend_kws:dict=frozendict(),**kwargs:dict,)->sns.FacetGrid:"""Create a composite plot that combines boxplots with backstrips,optionally hatched according to a categorical style variable.Provides a tidy-data, seaborn-like interface for backstrip elements. Unlikebackstrip, this function uses the seaborn.catplot interface to createboxplots (and then applies backstrips to the resulting axes).Parameters----------data : pd.DataFrameThe input dataset, where each row is an observation and each column is a feature.x : Optional[str], optionalThe name of the column in `data` to be plotted on the x-axis.y : Optional[str], optionalThe name of the column in `data` to be plotted on the y-axis.hue : Optional[str], optionalThe name of the column in `data` to assign boxplot colors.Backstrip colors are matched to the boxplot colors.style : Optional[str], optionalThe name of the column in `data` to assign backstrip hatch patterns.col : Optional[str], optionalVariable in `data` for facet wrapping the columns.row : Optional[str], optionalVariable in `data` for facet wrapping the rows.order : Optional[Sequence[str]], optionalThe order to plot the x or y categorical levels in.If None, order is assigned arbitrarily.hue_order : Optional[Sequence[str]], optionalThe order to assign hue levels with palette colors.If None, order is assigned arbitrarily.style_order : Optional[Sequence[str]], optionalThe order to assign style levels with hatch patterns.If None, order is assigned arbitrarily.hatches : Optional[Sequence[str]], optionalA sequence of hatch patterns to use for the styles.If None, an arbitrary sequence of hatch patterns is used.orient : {'v', 'h'}, default 'v'Orientation of the plot (vertical or horizontal).palette : Optional[Union[str, Sequence[str]]], optionalColors to use for the different levels of the `hue` variable.If None, the default seaborn color palette is used.backstrip_kws : dict, default dict()Additional keyword arguments for the backstrip function.legend_width_inches : float, default 1.5The width of the legend in inches.Overridden by any passed `legend_kws` options.legend_kws : dict, default dict()Additional keyword arguments for the legend.**kwargs : dictAdditional keyword arguments passed to `sns.catplot`.Returns-------sns.FacetGridA FacetGrid object which is the figure-level container for the plots.Notes-----If boxplot strips contain more than one style column value, they will behatched with both (or all) corresponding hatch patterns."""