{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Usetex text baseline\n\nComparison of text baselines computed for mathtext and usetex.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n\nplt.rcParams.update({\"mathtext.fontset\": \"cm\", \"mathtext.rm\": \"serif\"})\naxs = plt.figure(figsize=(2 * 3, 6.5)).subplots(1, 2)\nfor ax, usetex in zip(axs, [False, True]):\n ax.axvline(0, color=\"r\")\n test_strings = [\"lg\", r\"$\\frac{1}{2}\\pi$\", r\"$p^{3^A}$\", r\"$p_{3_2}$\"]\n for i, s in enumerate(test_strings):\n ax.axhline(i, color=\"r\")\n ax.text(0., 3 - i, s,\n usetex=usetex,\n verticalalignment=\"baseline\",\n size=50,\n bbox=dict(pad=0, ec=\"k\", fc=\"none\"))\n ax.set(xlim=(-0.1, 1.1), ylim=(-.8, 3.9), xticks=[], yticks=[],\n title=f\"usetex={usetex}\\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 }