.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_oo_api.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_plot_oo_api.py: Object-Oriented API =================== Build memes step-by-step or with method chaining using the :class:`~memeplotlib.Meme` class. .. GENERATED FROM PYTHON SOURCE LINES 10-14 Step-by-Step Construction -------------------------- Create a :class:`~memeplotlib.Meme`, set text on each position, then render. .. GENERATED FROM PYTHON SOURCE LINES 14-22 .. code-block:: Python from memeplotlib import Meme m = Meme("buzz") m.top("memes") m.bottom("memes everywhere") fig, ax = m.render() .. image-sg:: /auto_examples/images/sphx_glr_plot_oo_api_001.png :alt: plot oo api :srcset: /auto_examples/images/sphx_glr_plot_oo_api_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 23-27 Method Chaining ---------------- The fluent interface lets you build a meme in a single expression. .. GENERATED FROM PYTHON SOURCE LINES 27-30 .. code-block:: Python Meme("doge").top("such code").bottom("very bug").render() .. image-sg:: /auto_examples/images/sphx_glr_plot_oo_api_002.png :alt: plot oo api :srcset: /auto_examples/images/sphx_glr_plot_oo_api_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (
, ) .. GENERATED FROM PYTHON SOURCE LINES 31-35 Constructor Shorthand ---------------------- Text lines can also be passed directly to the constructor. .. GENERATED FROM PYTHON SOURCE LINES 35-38 .. code-block:: Python m = Meme("buzz", "memes", "memes everywhere") m.render() .. image-sg:: /auto_examples/images/sphx_glr_plot_oo_api_003.png :alt: plot oo api :srcset: /auto_examples/images/sphx_glr_plot_oo_api_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (
, ) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.883 seconds) .. _sphx_glr_download_auto_examples_plot_oo_api.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_oo_api.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_oo_api.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_oo_api.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_