.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/demo_barchart.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_demo_barchart.py: ==================== Demo with bar chart ==================== .. GENERATED FROM PYTHON SOURCE LINES 6-51 .. image-sg:: /examples/images/sphx_glr_demo_barchart_001.png :alt: demo barchart :srcset: /examples/images/sphx_glr_demo_barchart_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from mpl_poormans_3d import Poormans3d, Poormans3dFace import seaborn as sns df = sns.load_dataset("penguins") fig1, ax = plt.subplots(1, 1, num=1, clear=True, figsize=(5, 5)) fig1.subplots_adjust(left=0.2) sns.barplot(data=df, x="island", y="body_mass_g", hue="sex", ax=ax) ax.set_xlim(-0.7, 2.7) ax.patch.set(fc="0.7", alpha=1) # ax.legend_.remove() # now we turn the figure into 3d. from matplotlib.colors import LightSource ls = LightSource(azdeg=105) ls2 = LightSource(azdeg=180 + 105) from itertools import chain # patch_list_bar = [p for p in ax.patches][:6] # seabon creates 8 patches. We only need first 6. patch_list_bar = list(chain(*ax.containers)) for patch in patch_list_bar: patch.set_path_effects([ Poormans3d(ls, (10, 5), fraction=0.3), Poormans3dFace(ls, (0, 0)), ]) from mpl_visual_context.patheffects import ClipPathSelf ax.patch.set_path_effects([ Poormans3d(ls, (10, 5), fraction=0.3), # outer wall ClipPathSelf() | Poormans3dFace(ls2, (10, 5), fraction=0.5), ClipPathSelf() | Poormans3d(ls2, (10, 5), fraction=0.3), # inner wall ]) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.029 seconds) .. _sphx_glr_download_examples_demo_barchart.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_barchart.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_barchart.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_