{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# contour(X, Y, Z)\nPlot contour lines.\n\nSee `~matplotlib.axes.Axes.contour`.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\nplt.style.use('_mpl-gallery-nogrid')\n\n# make data\nX, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))\nZ = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2)\nlevels = np.linspace(np.min(Z), np.max(Z), 7)\n\n# plot\nfig, ax = plt.subplots()\n\nax.contour(X, Y, Z, levels=levels)\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 }