{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Infinite lines\n\n`~.axes.Axes.axvline` and `~.axes.Axes.axhline` draw infinite vertical /\nhorizontal lines, at given *x* / *y* positions. They are usually used to mark\nspecial data values, e.g. in this example the center and limit values of the\nsigmoid function.\n\n`~.axes.Axes.axline` draws infinite straight lines defined either by two\npoints or by a point and a slope.\n\n.. redirect-from:: /gallery/pyplot/axline\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nt = np.linspace(-10, 10, 100)\nsig = 1 / (1 + np.exp(-t))\n\nfig, ax = plt.subplots()\nax.axhline(y=0, color=\"black\", linestyle=\"--\")\nax.axhline(y=0.5, color=\"black\", linestyle=\":\")\nax.axhline(y=1.0, color=\"black\", linestyle=\"--\")\nax.axvline(color=\"grey\")\nax.axline((0, 0.5), slope=0.25, color=\"black\", linestyle=(0, (5, 5)))\nax.plot(t, sig, linewidth=2, label=r\"$\\sigma(t) = \\frac{1}{1 + e^{-t}}$\")\nax.set(xlim=(-10, 10), xlabel=\"t\")\nax.legend(fontsize=14)\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "`~.axes.Axes.axline` can also be used with a *transform* parameter, which\napplies to the point, but not to the slope. This can be useful for drawing\ndiagonal grid lines with a fixed slope, which stay in place when the\nplot limits are moved.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "fig, ax = plt.subplots()\nfor pos in np.linspace(-2, 1, 10):\n    ax.axline((pos, 0), slope=0.5, color='k', transform=ax.transAxes)\n\nax.set(xlim=(0, 1), ylim=(0, 1))\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. admonition:: References\n\n   The use of the following functions, methods, classes and modules is shown\n   in this example:\n\n   - `matplotlib.axes.Axes.axhline` / `matplotlib.pyplot.axhline`\n   - `matplotlib.axes.Axes.axvline` / `matplotlib.pyplot.axvline`\n   - `matplotlib.axes.Axes.axline` / `matplotlib.pyplot.axline`\n\n\n.. seealso::\n\n   `~.Axes.axhspan`, `~.Axes.axvspan` draw rectangles that span the Axes in one\n   direction and are bounded in the other direction.\n\n.. tags:: component: annotation\n\n"
      ]
    }
  ],
  "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.14.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}