{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Controlling style of text and labels using a dictionary\n\nThis example shows how to share parameters across many text objects and labels\nby creating a dictionary of options passed across several functions.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\nfont = {'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.13.2" } }, "nbformat": 4, "nbformat_minor": 0 }