{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# zorder (layer)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as patches\n\nfig, ax = plt.subplots(1,2,figsize=(8,4))\n\nx = np.linspace(-1,1,100)\ny = np.linspace(-1,1,100)\nx,y = np.meshgrid(x,y)\n\nw = 0.4\nx0 = 1 - w\ny0 = 1 - w\nr0 = patches.Rectangle(xy=(x0,y0), width=w, height=w, ec='#000', fill=True, fc=\"#000\", zorder=1)\nr1 = patches.Rectangle(xy=(x0,y0), width=w, height=w, ec='#000', fill=True, fc=\"#000\", zorder=2)\n\nf = lambda x,y: x*y\nax[0].contour(x,y,f(x,y), 100)\nax[1].contour(x,y,f(x,y), 100)\nax[0].set_title(\"zorder=1 (default)\")\nax[1].set_title(\"zorder=2\")\n\nax[0].add_patch(r0)\nax[1].add_patch(r1)\nfig.tight_layout()\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.9.16" } }, "nbformat": 4, "nbformat_minor": 0 }