.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "example_gallery/func_1d/fct_1d_stacked.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_example_gallery_func_1d_fct_1d_stacked.py: Stacked functions ================= Plot stacked functions using ``plot_function()``. .. GENERATED FROM PYTHON SOURCE LINES 7-43 .. image-sg:: /example_gallery/func_1d/images/sphx_glr_fct_1d_stacked_001.svg :alt: fct 1d stacked :srcset: /example_gallery/func_1d/images/sphx_glr_fct_1d_stacked_001.svg :class: sphx-glr-single-img .. code-block:: Python from scipy.stats import norm # Define the gaussian function of mean=0.5 and std_dev=3 def f(x): return 1000 * norm.pdf(x, loc=0.5, scale=3) ### from matplotlib import pyplot as plt from plothist import plot_function # Another function def g(x): return 1000 * norm.pdf(x, loc=2, scale=3) fig, ax = plt.subplots() plot_function( [f, g], range=(-10, 10), ax=ax, labels=["f1", "f2"], stacked=True, ) ax.set_xlabel("x") ax.set_ylabel("f(x)") ax.set_ylim(0) ax.legend() fig.savefig("fct_1d_stacked.svg", bbox_inches="tight") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.339 seconds) .. _sphx_glr_download_example_gallery_func_1d_fct_1d_stacked.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: fct_1d_stacked.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: fct_1d_stacked.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: fct_1d_stacked.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_