{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Project contour profiles onto a graph\nDemonstrates displaying a 3D surface while also projecting contour 'profiles'\nonto the 'walls' of the graph.\nSee :doc:`contourf3d_2` for the filled version.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n\nfrom mpl_toolkits.mplot3d import axes3d\n\nax = plt.figure().add_subplot(projection='3d')\nX, Y, Z = axes3d.get_test_data(0.05)\n\n# Plot the 3D surface\nax.plot_surface(X, Y, Z, edgecolor='royalblue', lw=0.5, rstride=8, cstride=8,\n alpha=0.3)\n\n# Plot projections of the contours for each dimension. By choosing offsets\n# that match the appropriate axes limits, the projected contours will sit on\n# the 'walls' of the graph.\nax.contour(X, Y, Z, zdir='z', offset=-100, cmap='coolwarm')\nax.contour(X, Y, Z, zdir='x', offset=-40, cmap='coolwarm')\nax.contour(X, Y, Z, zdir='y', offset=40, cmap='coolwarm')\n\nax.set(xlim=(-40, 40), ylim=(-40, 40), zlim=(-100, 100),\n xlabel='X', ylabel='Y', zlabel='Z')\n\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ".. tags::\n plot-type: 3D,\n component: axes,\n level: intermediate\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 }