{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Accented text\n\nMatplotlib supports accented characters via TeX mathtext or Unicode.\n\nUsing mathtext, the following accents are provided: \\\\hat, \\\\breve, \\\\grave,\n\\\\bar, \\\\acute, \\\\tilde, \\\\vec, \\\\dot, \\\\ddot. All of them have the same\nsyntax, e.g. \\\\bar{o} yields \"o overbar\", \\\\ddot{o} yields \"o umlaut\".\nShortcuts such as \\\\\"o \\\\'e \\\\`e \\\\~n \\\\.x \\\\^y are also supported.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n\n# Mathtext demo\nfig, ax = plt.subplots()\nax.plot(range(10))\nax.set_title(r'$\\ddot{o}\\acute{e}\\grave{e}\\hat{O}'\n r'\\breve{i}\\bar{A}\\tilde{n}\\vec{q}$', fontsize=20)\n\n# Shorthand is also supported and curly braces are optional\nax.set_xlabel(r\"\"\"$\\\"o\\ddot o \\'e\\`e\\~n\\.x\\^y$\"\"\", fontsize=20)\nax.text(4, 0.5, r\"$F=m\\ddot{x}$\")\nfig.tight_layout()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can also use Unicode characters directly in strings.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fig, ax = plt.subplots()\nax.set_title(\"GISCARD CHAHUT\u00c9 \u00c0 L'ASSEMBL\u00c9E\")\nax.set_xlabel(\"LE COUP DE D\u00c9 DE DE GAULLE\")\nax.set_ylabel('Andr\u00e9 was here!')\nax.text(0.2, 0.8, 'Institut f\u00fcr Festk\u00f6rperphysik', rotation=45)\nax.text(0.4, 0.2, 'AVA (check kerning)')\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 }