{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Simple Legend01\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n\nfig = plt.figure()\n\nax = fig.add_subplot(211)\nax.plot([1, 2, 3], label=\"test1\")\nax.plot([3, 2, 1], label=\"test2\")\n# Place a legend above this subplot, expanding itself to\n# fully use the given bounding box.\nax.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc='lower left',\n ncols=2, mode=\"expand\", borderaxespad=0.)\n\nax = fig.add_subplot(223)\nax.plot([1, 2, 3], label=\"test1\")\nax.plot([3, 2, 1], label=\"test2\")\n# Place a legend to the right of this smaller subplot.\nax.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0.)\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 }