{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Scales overview\n\nIllustrate the scale transformations applied to axes, e.g. log, symlog, logit.\n\nSee `matplotlib.scale` for a full list of built-in scales,\n:doc:`/gallery/scales/custom_scale` for how to create your own scale, and\n:doc:`/gallery/mplot3d/scales3d` for using scales on 3D axes.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nx = np.arange(400)\ny = np.linspace(0.002, 1, 400)\n\nfig, axs = plt.subplots(3, 2, figsize=(6, 8), layout='constrained')\n\naxs[0, 0].plot(x, y)\naxs[0, 0].set_yscale('linear')\naxs[0, 0].set_title('linear')\naxs[0, 0].grid(True)\n\naxs[0, 1].plot(x, y)\naxs[0, 1].set_yscale('log')\naxs[0, 1].set_title('log')\naxs[0, 1].grid(True)\n\naxs[1, 0].plot(x, y - y.mean())\naxs[1, 0].set_yscale('symlog', linthresh=0.02)\naxs[1, 0].set_title('symlog')\naxs[1, 0].grid(True)\n\naxs[1, 1].plot(x, y)\naxs[1, 1].set_yscale('logit')\naxs[1, 1].set_title('logit')\naxs[1, 1].grid(True)\n\naxs[2, 0].plot(x, y - y.mean())\naxs[2, 0].set_yscale('asinh', linear_width=0.01)\naxs[2, 0].set_title('asinh')\naxs[2, 0].grid(True)\n\n\n# Function x**(1/2)\ndef forward(x):\n    return x**(1/2)\n\n\ndef inverse(x):\n    return x**2\n\n\naxs[2, 1].plot(x, y)\naxs[2, 1].set_yscale('function', functions=(forward, inverse))\naxs[2, 1].set_title('function: $x^{1/2}$')\naxs[2, 1].grid(True)\naxs[2, 1].set_yticks(np.arange(0, 1.2, 0.2))\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. admonition:: References\n\n   The use of the following functions, methods, classes and modules is shown\n   in this example:\n\n   - `matplotlib.axes.Axes.set_xscale`\n   - `matplotlib.axes.Axes.set_yscale`\n   - `matplotlib.scale.LinearScale`\n   - `matplotlib.scale.LogScale`\n   - `matplotlib.scale.SymmetricalLogScale`\n   - `matplotlib.scale.LogitScale`\n   - `matplotlib.scale.FuncScale`\n\n"
      ]
    }
  ],
  "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
}