{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# The default tick formatter\n\nBy default, tick labels are formatted using a `.ScalarFormatter`, which can be\nconfigured via `~.axes.Axes.ticklabel_format`. This example illustrates some\npossible configurations:\n\n- Default.\n- ``useMathText=True``: Fancy formatting of mathematical expressions.\n- ``useOffset=False``: Do not use offset notation; see\n `.ScalarFormatter.set_useOffset`.\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(0, 1, .01)\nfig, axs = plt.subplots(\n 3, 3, figsize=(9, 9), layout=\"constrained\", gridspec_kw={\"hspace\": 0.1})\n\nfor col in axs.T:\n col[0].plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5)\n col[1].plot(x * 1e5, x * 1e-4)\n col[2].plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10)\n\nfor ax in axs[:, 1]:\n ax.ticklabel_format(useMathText=True)\nfor ax in axs[:, 2]:\n ax.ticklabel_format(useOffset=False)\n\nplt.rcParams.update({\"axes.titleweight\": \"bold\", \"axes.titley\": 1.1})\naxs[0, 0].set_title(\"default settings\")\naxs[0, 1].set_title(\"useMathText=True\")\naxs[0, 2].set_title(\"useOffset=False\")\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.13.2" } }, "nbformat": 4, "nbformat_minor": 0 }