{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Demo of 3D bar charts\n\nA basic demo of how to plot 3D bars with and without shading.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\n# set up the figure and Axes\nfig = plt.figure(figsize=(8, 3))\nax1 = fig.add_subplot(121, projection='3d')\nax2 = fig.add_subplot(122, projection='3d')\n\n# fake data\n_x = np.arange(4)\n_y = np.arange(5)\n_xx, _yy = np.meshgrid(_x, _y)\nx, y = _xx.ravel(), _yy.ravel()\n\ntop = x + y\nbottom = np.zeros_like(top)\nwidth = depth = 1\n\nax1.bar3d(x, y, bottom, width, depth, top, shade=True)\nax1.set_title('Shaded')\n\nax2.bar3d(x, y, bottom, width, depth, top, shade=False)\nax2.set_title('Not Shaded')\n\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ".. tags::\n plot-type: 3D,\n styling: texture,\n plot-type: bar,\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 }