.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plots/customizing.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_auto_examples_plots_customizing.py: .. _exa-customizing-plots: Customizing plots ================= With the exception of :mod:`plot.brain` plots, Eelbrain's plots are all based on :mod:`matplotlib`. A lot of fine control over the plots can be achieved through two means: - Customizing Matplotlib globally, before calling Eelbrain plotting functions, through `styles or ``rcParams`` `_ - Accessing and modifying components of the plots after calling Eelbrain plotting functions .. GENERATED FROM PYTHON SOURCE LINES 31-37 .. code-block:: Python # sphinx_gallery_thumbnail_number = 3 from eelbrain import * import matplotlib.style ds = datasets.get_uv() .. GENERATED FROM PYTHON SOURCE LINES 38-41 Styles ^^^^^^ Matplotlib offers several styles .. GENERATED FROM PYTHON SOURCE LINES 41-51 .. code-block:: Python p = plot.Boxplot('fltvar', 'A % B', match='rm', data=ds, w=2) # Apply a style matplotlib.style.use('ggplot') p = plot.Boxplot('fltvar', 'A % B', match='rm', data=ds, w=2) matplotlib.style.use('bmh') p = plot.Boxplot('fltvar', 'A % B', match='rm', data=ds, w=2) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/plots/images/sphx_glr_customizing_001.png :alt: customizing :srcset: /auto_examples/plots/images/sphx_glr_customizing_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/plots/images/sphx_glr_customizing_002.png :alt: customizing :srcset: /auto_examples/plots/images/sphx_glr_customizing_002.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/plots/images/sphx_glr_customizing_003.png :alt: customizing :srcset: /auto_examples/plots/images/sphx_glr_customizing_003.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 52-55 ``rcParams`` ^^^^^^^^^^^^ Individual styles parameters can be modified directly in``rcParams`` .. GENERATED FROM PYTHON SOURCE LINES 55-63 .. code-block:: Python matplotlib.rcParams['font.family'] = 'serif' matplotlib.rcParams['font.size'] = 8 p = plot.Boxplot('fltvar', 'A % B', match='rm', data=ds, w=2) # revert back to the default style matplotlib.style.use('default') .. image-sg:: /auto_examples/plots/images/sphx_glr_customizing_004.png :alt: customizing :srcset: /auto_examples/plots/images/sphx_glr_customizing_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 64-69 Modifying components ^^^^^^^^^^^^^^^^^^^^ Matplotlib can be used to fully customize a plot's appearance by accessing the underlying :class:`matplotlib.figure.Figure` object through the plot's :attr:`.figure` aatribute. .. GENERATED FROM PYTHON SOURCE LINES 69-81 .. code-block:: Python p = plot.Boxplot('fltvar', 'A % B', match='rm', data=ds, w=2) p = plot.Boxplot('fltvar', 'A % B', match='rm', data=ds, w=2, h=3, xlabel=False) ax = p.figure.axes[0] ax.set_xticklabels(['A long label', 'An even longer label', 'Another label', 'And yet another one'], rotation=45, ha='right') ax.grid(axis='y') ax.set_yticks([-2, 0, 2]) ax.tick_params('y', left=False) for spine in ax.spines.values(): spine.set_visible(False) p.figure.tight_layout() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/plots/images/sphx_glr_customizing_005.png :alt: customizing :srcset: /auto_examples/plots/images/sphx_glr_customizing_005.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/plots/images/sphx_glr_customizing_006.png :alt: customizing :srcset: /auto_examples/plots/images/sphx_glr_customizing_006.png :class: sphx-glr-multi-img .. _sphx_glr_download_auto_examples_plots_customizing.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: customizing.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: customizing.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: customizing.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_