{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Simple axis tick label and tick directions\n\nFirst subplot moves the tick labels to inside the spines.\nSecond subplot moves the ticks to inside the spines.\nThese effects can be obtained for a standard Axes by `~.Axes.tick_params`.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n\nimport mpl_toolkits.axisartist as axisartist\n\n\ndef setup_axes(fig, pos):\n ax = fig.add_subplot(pos, axes_class=axisartist.Axes)\n ax.set_yticks([0.2, 0.8])\n ax.set_xticks([0.2, 0.8])\n return ax\n\n\nfig = plt.figure(figsize=(5, 2))\nfig.subplots_adjust(wspace=0.4, bottom=0.3)\n\nax1 = setup_axes(fig, 121)\nax1.set_xlabel(\"ax1 X-label\")\nax1.set_ylabel(\"ax1 Y-label\")\n\nax1.axis[:].invert_ticklabel_direction()\n\nax2 = setup_axes(fig, 122)\nax2.set_xlabel(\"ax2 X-label\")\nax2.set_ylabel(\"ax2 Y-label\")\n\nax2.axis[:].major_ticks.set_tick_out(False)\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 }