{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Text and mathtext using pyplot\n\nSet the special text objects `~.pyplot.title`, `~.pyplot.xlabel`, and\n`~.pyplot.ylabel` through the dedicated pyplot functions. Additional text\nobjects can be placed in the Axes using `~.pyplot.text`.\n\nYou can use TeX-like mathematical typesetting in all texts; see also\n`mathtext`.\n\n.. redirect-from:: /gallery/pyplots/pyplot_mathtext\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\nt = np.arange(0.0, 2.0, 0.01)\ns = np.sin(2*np.pi*t)\n\nplt.plot(t, s)\nplt.text(0, -1, r'Hello, world!', fontsize=15)\nplt.title(r'$\\mathcal{A}\\sin(\\omega t)$', fontsize=20)\nplt.xlabel('Time [s]')\nplt.ylabel('Voltage [mV]')\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.pyplot.hist`\n - `matplotlib.pyplot.xlabel`\n - `matplotlib.pyplot.ylabel`\n - `matplotlib.pyplot.text`\n - `matplotlib.pyplot.grid`\n - `matplotlib.pyplot.show`\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.13.2" } }, "nbformat": 4, "nbformat_minor": 0 }