{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Logarithmus\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib\n\nplt.figure()\n\nplt.subplots_adjust(hspace=0.4)\nt = np.arange(0.01, 20.0, 0.01)\n\n# log y axis\nplt.subplot(221)\nplt.semilogy(t, np.exp(-t / 5.0))\nplt.title(\"semilogy\")\nplt.grid(True)\n\n# log x axis\nplt.subplot(222)\nplt.semilogx(t, np.sin(2 * np.pi * t))\nplt.title(\"semilogx\")\nplt.grid(True)\n\n# log x and y axis\nplt.subplot(223)\n\nif matplotlib.__version__ < \"3.3.0\":\n plt.loglog(t, 20 * np.exp(-t / 10.0), basex=2)\nelse:\n plt.loglog(t, 20 * np.exp(-t / 10.0), base=2)\nplt.grid(True)\nplt.title(\"loglog base 4 on x\")\n\n# with errorbars: clip non-positive values\nax = plt.subplot(224)\n\nif matplotlib.__version__ < \"3.3.0\":\n ax.set_xscale(\"log\", nonposx=\"clip\")\n ax.set_yscale(\"log\", nonposy=\"clip\")\nelse:\n ax.set_xscale(\"log\", nonpositive=\"clip\")\n ax.set_yscale(\"log\", nonpositive=\"clip\")\n\nx = 10.0 ** np.linspace(0.0, 2.0, 20)\ny = x ** 2.0\nplt.errorbar(x, y, xerr=0.1 * x, yerr=5.0 + 0.75 * y)\nax.set_ylim(ymin=0.1)\nax.set_title(\"Errorbars go negative\")\n\n\nplt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 0 }