.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "11_demos\python_packages\matplotlib\demo_log.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_11_demos_python_packages_matplotlib_demo_log.py: Logarithmus ============== .. GENERATED FROM PYTHON SOURCE LINES 5-55 .. image-sg:: /11_demos/python_packages/matplotlib/images/sphx_glr_demo_log_001.png :alt: semilogy, semilogx, loglog base 4 on x, Errorbars go negative :srcset: /11_demos/python_packages/matplotlib/images/sphx_glr_demo_log_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np import matplotlib.pyplot as plt import matplotlib plt.figure() plt.subplots_adjust(hspace=0.4) t = np.arange(0.01, 20.0, 0.01) # log y axis plt.subplot(221) plt.semilogy(t, np.exp(-t / 5.0)) plt.title("semilogy") plt.grid(True) # log x axis plt.subplot(222) plt.semilogx(t, np.sin(2 * np.pi * t)) plt.title("semilogx") plt.grid(True) # log x and y axis plt.subplot(223) if matplotlib.__version__ < "3.3.0": plt.loglog(t, 20 * np.exp(-t / 10.0), basex=2) else: plt.loglog(t, 20 * np.exp(-t / 10.0), base=2) plt.grid(True) plt.title("loglog base 4 on x") # with errorbars: clip non-positive values ax = plt.subplot(224) if matplotlib.__version__ < "3.3.0": ax.set_xscale("log", nonposx="clip") ax.set_yscale("log", nonposy="clip") else: ax.set_xscale("log", nonpositive="clip") ax.set_yscale("log", nonpositive="clip") x = 10.0 ** np.linspace(0.0, 2.0, 20) y = x**2.0 plt.errorbar(x, y, xerr=0.1 * x, yerr=5.0 + 0.75 * y) ax.set_ylim(ymin=0.1) ax.set_title("Errorbars go negative") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.250 seconds) .. _sphx_glr_download_11_demos_python_packages_matplotlib_demo_log.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_log.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_log.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: demo_log.zip `