{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Text fontdict\n\nDemo using fontdict to control style of text and labels.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\nimport matplotlib.pyplot as plt\n\n\nfont = {\n \"family\": \"serif\",\n \"color\": \"darkred\",\n \"weight\": \"normal\",\n \"size\": 16,\n}\n\nx = np.linspace(0.0, 5.0, 100)\ny = np.cos(2 * np.pi * x) * np.exp(-x)\n\nplt.plot(x, y, \"k\")\nplt.title(\"Damped exponential decay\", fontdict=font)\nplt.text(2, 0.65, r\"$\\cos(2 \\pi t) \\exp(-t)$\", fontdict=font)\nplt.xlabel(\"time (s)\", fontdict=font)\nplt.ylabel(\"voltage (mV)\", fontdict=font)\n\n# Tweak spacing to prevent clipping of ylabel\nplt.subplots_adjust(left=0.15)\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.8.10" } }, "nbformat": 4, "nbformat_minor": 0 }