{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Inches and centimeters\n\nThe example illustrates the ability to override default x and y units (ax1) to\ninches and centimeters using the *xunits* and *yunits* parameters for the\n`~.axes.Axes.plot` function. Note that conversions are applied to get numbers\nto correct units.\n\n.. only:: builder_html\n\n   This example requires :download:`basic_units.py <basic_units.py>`\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from basic_units import cm, inch\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\ncms = cm * np.arange(0, 10, 2)\n\nfig, axs = plt.subplots(2, 2, layout='constrained')\n\naxs[0, 0].plot(cms, cms)\n\naxs[0, 1].plot(cms, cms, xunits=cm, yunits=inch)\n\naxs[1, 0].plot(cms, cms, xunits=inch, yunits=cm)\naxs[1, 0].set_xlim(-1, 4)  # scalars are interpreted in current units\n\naxs[1, 1].plot(cms, cms, xunits=inch, yunits=inch)\naxs[1, 1].set_xlim(3*cm, 6*cm)  # cm are converted to inches\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.7"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}