{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Automatic text offsetting\n\nThis example demonstrates mplot3d's offset text display.\nAs one rotates the 3D figure, the offsets should remain oriented the\nsame way as the axis label, and should also be located \"away\"\nfrom the center of the plot.\n\nThis demo triggers the display of the offset text for the x- and\ny-axis by adding 1e5 to X and Y. Anything less would not\nautomatically trigger it.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\nax = plt.figure().add_subplot(projection='3d')\n\nX, Y = np.mgrid[0:6*np.pi:0.25, 0:4*np.pi:0.25]\nZ = np.sqrt(np.abs(np.cos(X) + np.cos(Y)))\n\nax.plot_surface(X + 1e5, Y + 1e5, Z, cmap='autumn', cstride=2, rstride=2)\n\nax.set_xlabel(\"X label\")\nax.set_ylabel(\"Y label\")\nax.set_zlabel(\"Z label\")\nax.set_zlim(0, 2)\n\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ".. tags::\n plot-type: 3D,\n component: label,\n interactivity: pan,\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 }