{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Axis line styles\n\nThis example shows some configurations for axis style.\n\nNote: The `mpl_toolkits.axisartist` Axes classes may be confusing for new\nusers. If the only aim is to obtain arrow heads at the ends of the axes,\nrather check out the :doc:`/gallery/spines/centered_spines_with_arrows`\nexample.\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.axisartist.axislines import AxesZero\n\nfig = plt.figure()\nax = fig.add_subplot(axes_class=AxesZero)\n\nfor direction in [\"xzero\", \"yzero\"]:\n # adds arrows at the ends of each axis\n ax.axis[direction].set_axisline_style(\"-|>\")\n\n # adds X and Y-axis from the origin\n ax.axis[direction].set_visible(True)\n\nfor direction in [\"left\", \"right\", \"bottom\", \"top\"]:\n # hides borders\n ax.axis[direction].set_visible(False)\n\nx = np.linspace(-0.5, 1., 100)\nax.plot(x, np.sin(x*np.pi))\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.13.2" } }, "nbformat": 4, "nbformat_minor": 0 }