{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Ticklabel alignment\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], labels=[\"short\", \"loooong\"])\n    ax.set_xticks([0.2, 0.8], labels=[r\"$\\frac{1}{2}\\pi$\", r\"$\\pi$\"])\n    return ax\n\n\nfig = plt.figure(figsize=(3, 5))\nfig.subplots_adjust(left=0.5, hspace=0.7)\n\nax = setup_axes(fig, 311)\nax.set_ylabel(\"ha=right\")\nax.set_xlabel(\"va=baseline\")\n\nax = setup_axes(fig, 312)\nax.axis[\"left\"].major_ticklabels.set_ha(\"center\")\nax.axis[\"bottom\"].major_ticklabels.set_va(\"top\")\nax.set_ylabel(\"ha=center\")\nax.set_xlabel(\"va=top\")\n\nax = setup_axes(fig, 313)\nax.axis[\"left\"].major_ticklabels.set_ha(\"left\")\nax.axis[\"bottom\"].major_ticklabels.set_va(\"bottom\")\nax.set_ylabel(\"ha=left\")\nax.set_xlabel(\"va=bottom\")\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
}