.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/text_labels_and_annotations/fonts_demo_kw.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. meta:: :keywords: codex .. 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_gallery_text_labels_and_annotations_fonts_demo_kw.py: ============================== Fonts demo (keyword arguments) ============================== Set font properties using keyword arguments. See :doc:`fonts_demo` to achieve the same effect using setters. .. GENERATED FROM PYTHON SOURCE LINES 10-57 .. image-sg:: /gallery/text_labels_and_annotations/images/sphx_glr_fonts_demo_kw_001.png :alt: fonts demo kw :srcset: /gallery/text_labels_and_annotations/images/sphx_glr_fonts_demo_kw_001.png, /gallery/text_labels_and_annotations/images/sphx_glr_fonts_demo_kw_001_2_00x.png 2.00x :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt fig = plt.figure() alignment = {'horizontalalignment': 'center', 'verticalalignment': 'baseline'} yp = [0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2] # Show family options fig.text(0.1, 0.9, 'family', size='large', **alignment) families = ['serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'] for k, family in enumerate(families): fig.text(0.1, yp[k], family, family=family, **alignment) # Show style options fig.text(0.3, 0.9, 'style', **alignment) styles = ['normal', 'italic', 'oblique'] for k, style in enumerate(styles): fig.text(0.3, yp[k], style, family='sans-serif', style=style, **alignment) # Show variant options fig.text(0.5, 0.9, 'variant', **alignment) variants = ['normal', 'small-caps'] for k, variant in enumerate(variants): fig.text(0.5, yp[k], variant, family='serif', variant=variant, **alignment) # Show weight options fig.text(0.7, 0.9, 'weight', **alignment) weights = ['light', 'normal', 'medium', 'semibold', 'bold', 'heavy', 'black'] for k, weight in enumerate(weights): fig.text(0.7, yp[k], weight, weight=weight, **alignment) # Show size options fig.text(0.9, 0.9, 'size', **alignment) sizes = [ 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'] for k, size in enumerate(sizes): fig.text(0.9, yp[k], size, size=size, **alignment) # Show bold italic fig.text(0.3, 0.1, 'bold italic', style='italic', weight='bold', size='x-small', **alignment) fig.text(0.3, 0.2, 'bold italic', style='italic', weight='bold', size='medium', **alignment) fig.text(0.3, 0.3, 'bold italic', style='italic', weight='bold', size='x-large', **alignment) plt.show() .. _sphx_glr_download_gallery_text_labels_and_annotations_fonts_demo_kw.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: fonts_demo_kw.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: fonts_demo_kw.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_