{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Custom Ticker\n\nThe :mod:`matplotlib.ticker` module defines many preset tickers, but was\nprimarily designed for extensibility, i.e., to support user customized ticking.\n\nIn this example, a user defined function is used to format the ticks in\nmillions of dollars on the y-axis.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\n\ndef millions(x, pos):\n    \"\"\"The two arguments are the value and tick position.\"\"\"\n    return f'${x*1e-6:1.1f}M'\n\n\nfig, ax = plt.subplots()\n# set_major_formatter internally creates a FuncFormatter from the callable.\nax.yaxis.set_major_formatter(millions)\nmoney = [1.5e5, 2.5e6, 5.5e6, 2.0e7]\nax.bar(['Bill', 'Fred', 'Mary', 'Sue'], money)\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.axis.Axis.set_major_formatter`\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
}