Violing Chart

test bbox alpha path effect
/home/docs/checkouts/readthedocs.org/user_builds/mpl-visual-context/envs/0.9.2/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/home/docs/checkouts/readthedocs.org/user_builds/mpl-visual-context/envs/0.9.2/lib/python3.10/site-packages/seaborn/categorical.py:641: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
  grouped_vals = vals.groupby(grouper)

import numpy as np
import matplotlib.pyplot as plt
import seaborn

seaborn.set()

tips = seaborn.load_dataset("tips")

fig, ax = plt.subplots(num=1, clear=True)
seaborn.violinplot(x='day', y='tip', data=tips, ax=ax)

from matplotlib.collections import PolyCollection
# from mpl_visual_context.patheffects_image_bbox import (
#     BboxAlphaPathEffect,
#     ColorBboxAlpha,
# )
import mpl_visual_context.patheffects as pe

colls = [p for p in ax.collections if isinstance(p, PolyCollection)]

from mpl_visual_context.patheffects_base import AbstractPathEffect
from matplotlib.transforms import BboxTransformTo, Bbox, TransformedPath

from mpl_visual_context.patheffects_image_box import AlphaGradient

pe_list = [
    AlphaGradient("0.7 > 0.1 > 0.7"),
    (pe.StrokeColorFromFillColor() | pe.HLSModify(l="-50%") | pe.StrokeOnly()),
]

for x, coll in enumerate(colls):
    coll.set_path_effects(pe_list)

plt.show()

Total running time of the script: (0 minutes 0.213 seconds)

Gallery generated by Sphinx-Gallery