{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Fill between 3D lines\n\nDemonstrate how to fill the space between 3D lines with surfaces. Here we\ncreate a sort of \"lampshade\" shape.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\nN = 50\ntheta = np.linspace(0, 2*np.pi, N)\n\nx1 = np.cos(theta)\ny1 = np.sin(theta)\nz1 = 0.1 * np.sin(6 * theta)\n\nx2 = 0.6 * np.cos(theta)\ny2 = 0.6 * np.sin(theta)\nz2 = 2 # Note that scalar values work in addition to length N arrays\n\nfig = plt.figure()\nax = fig.add_subplot(projection='3d')\nax.fill_between(x1, y1, z1, x2, y2, z2, alpha=0.5, edgecolor='k')\n\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ".. tags::\n plot-type: 3D,\n plot-type: fill_between,\n level: beginner\n\n" ] } ], "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 }