{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Simple axis pad\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nfrom matplotlib.projections import PolarAxes\nfrom matplotlib.transforms import Affine2D\nimport mpl_toolkits.axisartist as axisartist\nfrom mpl_toolkits.axisartist import angle_helper, grid_finder\nfrom mpl_toolkits.axisartist.grid_helper_curvelinear import GridHelperCurveLinear\n\n\ndef setup_axes(fig, rect):\n    \"\"\"Polar projection, but in a rectangular box.\"\"\"\n    # see demo_curvelinear_grid.py for details\n    grid_helper = GridHelperCurveLinear(\n        Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform(),\n        extreme_finder=angle_helper.ExtremeFinderCycle(\n            20, 20,\n            lon_cycle=360, lat_cycle=None,\n            lon_minmax=None, lat_minmax=(0, np.inf),\n        ),\n        grid_locator1=angle_helper.LocatorDMS(12),\n        grid_locator2=grid_finder.MaxNLocator(5),\n        tick_formatter1=angle_helper.FormatterDMS(),\n    )\n    ax = fig.add_subplot(\n        rect, axes_class=axisartist.Axes, grid_helper=grid_helper,\n        aspect=1, xlim=(-5, 12), ylim=(-5, 10))\n    ax.axis[:].set_visible(False)\n    return ax\n\n\ndef add_floating_axis1(ax1):\n    ax1.axis[\"lat\"] = axis = ax1.new_floating_axis(0, 30)\n    axis.label.set_text(r\"$\\theta = 30^{\\circ}$\")\n    axis.label.set_visible(True)\n\n    return axis\n\n\ndef add_floating_axis2(ax1):\n    ax1.axis[\"lon\"] = axis = ax1.new_floating_axis(1, 6)\n    axis.label.set_text(r\"$r = 6$\")\n    axis.label.set_visible(True)\n\n    return axis\n\n\nfig = plt.figure(figsize=(9, 3.))\nfig.subplots_adjust(left=0.01, right=0.99, bottom=0.01, top=0.99,\n                    wspace=0.01, hspace=0.01)\n\n\ndef ann(ax1, d):\n    ax1.annotate(d, (0.5, 1), (5, -5),\n                 xycoords=\"axes fraction\", textcoords=\"offset points\",\n                 va=\"top\", ha=\"center\")\n\n\nax1 = setup_axes(fig, rect=231)\naxis = add_floating_axis1(ax1)\nann(ax1, \"default\")\n\nax1 = setup_axes(fig, rect=232)\naxis = add_floating_axis1(ax1)\naxis.major_ticklabels.set_pad(10)\nann(ax1, \"ticklabels.set_pad(10)\")\n\nax1 = setup_axes(fig, rect=233)\naxis = add_floating_axis1(ax1)\naxis.label.set_pad(20)\nann(ax1, \"label.set_pad(20)\")\n\nax1 = setup_axes(fig, rect=234)\naxis = add_floating_axis1(ax1)\naxis.major_ticks.set_tick_direction(\"in\")\nann(ax1, 'ticks.set_tick_direction(\"in\")')\n\nax1 = setup_axes(fig, rect=235)\naxis = add_floating_axis1(ax1)\naxis.major_ticks.set_tick_direction(\"out\")\nann(ax1, 'ticks.set_tick_direction(\"out\")')\n\nax1 = setup_axes(fig, rect=236)\naxis = add_floating_axis1(ax1)\naxis.major_ticks.set_tick_direction(\"inout\")\nann(ax1, 'ticks.set_tick_direction(\"inout\")')\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
}