{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.add_subplot(1, 1, 1)\n",
    "ax.spines['left'].set_position('center')\n",
    "ax.spines['bottom'].set_position('center')\n",
    "ax.spines['right'].set_color('none')\n",
    "ax.spines['top'].set_color('none')\n",
    "ax.xaxis.set_ticks_position('bottom')\n",
    "ax.yaxis.set_ticks_position('left')\n",
    "plt.plot()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "fig = plt.figure()\n",
    "x = np.linspace(-np.pi, np.pi, 100)\n",
    "y = 2 * np.sin(x)\n",
    "\n",
    "ax = fig.add_subplot(2, 2, 1)\n",
    "ax.set_title('centered spines')\n",
    "ax.plot(x, y)\n",
    "ax.spines['left'].set_position('center')\n",
    "ax.spines['right'].set_color('none')\n",
    "ax.spines['bottom'].set_position('center')\n",
    "ax.spines['top'].set_color('none')\n",
    "ax.spines['left'].set_smart_bounds(True)\n",
    "ax.spines['bottom'].set_smart_bounds(True)\n",
    "ax.xaxis.set_ticks_position('bottom')\n",
    "ax.yaxis.set_ticks_position('left')\n",
    "\n",
    "ax = fig.add_subplot(2, 2, 2)\n",
    "ax.set_title('zeroed spines')\n",
    "ax.plot(x, y)\n",
    "ax.spines['left'].set_position('zero')\n",
    "ax.spines['right'].set_color('none')\n",
    "ax.spines['bottom'].set_position('zero')\n",
    "ax.spines['top'].set_color('none')\n",
    "ax.spines['left'].set_smart_bounds(True)\n",
    "ax.spines['bottom'].set_smart_bounds(True)\n",
    "ax.xaxis.set_ticks_position('bottom')\n",
    "ax.yaxis.set_ticks_position('left')\n",
    "\n",
    "ax = fig.add_subplot(2, 2, 3)\n",
    "ax.set_title('spines at axes (0.6, 0.1)')\n",
    "ax.plot(x, y)\n",
    "ax.spines['left'].set_position(('axes', 0.6))\n",
    "ax.spines['right'].set_color('none')\n",
    "ax.spines['bottom'].set_position(('axes', 0.1))\n",
    "ax.spines['top'].set_color('none')\n",
    "ax.spines['left'].set_smart_bounds(True)\n",
    "ax.spines['bottom'].set_smart_bounds(True)\n",
    "ax.xaxis.set_ticks_position('bottom')\n",
    "ax.yaxis.set_ticks_position('left')\n",
    "\n",
    "ax = fig.add_subplot(2, 2, 4)\n",
    "ax.set_title('spines at data (1, 2)')\n",
    "ax.plot(x, y)\n",
    "ax.spines['left'].set_position(('data', 1))\n",
    "ax.spines['right'].set_color('none')\n",
    "ax.spines['bottom'].set_position(('data', 2))\n",
    "ax.spines['top'].set_color('none')\n",
    "ax.spines['left'].set_smart_bounds(True)\n",
    "ax.spines['bottom'].set_smart_bounds(True)\n",
    "ax.xaxis.set_ticks_position('bottom')\n",
    "ax.yaxis.set_ticks_position('left')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.add_subplot(1, 1, 1)\n",
    "x = np.linspace(-5,5,100)\n",
    "ax.spines['left'].set_position('center')\n",
    "ax.spines['bottom'].set_position('center')\n",
    "ax.spines['right'].set_color('none')\n",
    "ax.spines['top'].set_color('none')\n",
    "ax.xaxis.set_ticks_position('bottom')\n",
    "ax.yaxis.set_ticks_position('left')\n",
    "plt.plot(x, 2*x+1, '-r', label='y=2x+1')\n",
    "plt.plot(x, 2*x-1,'-.g', label='y=2x-1')\n",
    "plt.plot(x, 2*x+3,':b', label='y=2x+3')\n",
    "plt.plot(x, 2*x-3,'--m', label='y=2x-3')\n",
    "plt.legend(loc='upper left')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
