{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# floating_axis demo\n\nAxis within rectangular frame.\n\nThe following code demonstrates how to put a floating polar curve within a\nrectangular box. In order to get a better sense of polar curves, please look at\n:doc:`/gallery/axisartist/demo_curvelinear_grid`.\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\nfrom mpl_toolkits.axisartist import GridHelperCurveLinear, HostAxes\nimport mpl_toolkits.axisartist.angle_helper as angle_helper\n\n\ndef curvelinear_test2(fig):\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        tick_formatter1=angle_helper.FormatterDMS(),\n    )\n    ax1 = fig.add_subplot(axes_class=HostAxes, grid_helper=grid_helper)\n\n    # Now create floating axis\n\n    # floating axis whose first coordinate (theta) is fixed at 60\n    ax1.axis[\"lat\"] = axis = ax1.new_floating_axis(0, 60)\n    axis.label.set_text(r\"$\\theta = 60^{\\circ}$\")\n    axis.label.set_visible(True)\n\n    # floating axis whose second coordinate (r) is fixed at 6\n    ax1.axis[\"lon\"] = axis = ax1.new_floating_axis(1, 6)\n    axis.label.set_text(r\"$r = 6$\")\n\n    ax1.set_aspect(1.)\n    ax1.set_xlim(-5, 12)\n    ax1.set_ylim(-5, 10)\n\n    ax1.grid(True)\n\n\nfig = plt.figure(figsize=(5, 5))\ncurvelinear_test2(fig)\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.7"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}