{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Custom spines with axisartist\n\nThis example showcases the use of :mod:`.axisartist` to draw spines at custom\npositions (here, at ``y = 0``).\n\nNote, however, that it is simpler to achieve this effect using standard\n`.Spine` methods, as demonstrated in\n:doc:`/gallery/spines/centered_spines_with_arrows`.\n\n.. redirect-from:: /gallery/axisartist/simple_axisline2\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nfrom mpl_toolkits import axisartist\n\nfig = plt.figure(figsize=(6, 3), layout=\"constrained\")\n# To construct Axes of two different classes, we need to use gridspec (or\n# MATLAB-style add_subplot calls).\ngs = fig.add_gridspec(1, 2)\n\n\nax0 = fig.add_subplot(gs[0, 0], axes_class=axisartist.Axes)\n# Make a new axis along the first (x) axis which passes through y=0.\nax0.axis[\"y=0\"] = ax0.new_floating_axis(nth_coord=0, value=0,\n                                        axis_direction=\"bottom\")\nax0.axis[\"y=0\"].toggle(all=True)\nax0.axis[\"y=0\"].label.set_text(\"y = 0\")\n# Make other axis invisible.\nax0.axis[\"bottom\", \"top\", \"right\"].set_visible(False)\n\n\n# Alternatively, one can use AxesZero, which automatically sets up two\n# additional axis, named \"xzero\" (the y=0 axis) and \"yzero\" (the x=0 axis).\nax1 = fig.add_subplot(gs[0, 1], axes_class=axisartist.axislines.AxesZero)\n# \"xzero\" and \"yzero\" default to invisible; make xzero axis visible.\nax1.axis[\"xzero\"].set_visible(True)\nax1.axis[\"xzero\"].label.set_text(\"Axis Zero\")\n# Make other axis invisible.\nax1.axis[\"bottom\", \"top\", \"right\"].set_visible(False)\n\n\n# Draw some sample data.\nx = np.arange(0, 2*np.pi, 0.01)\nax0.plot(x, np.sin(x))\nax1.plot(x, np.sin(x))\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.14.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}