{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# voxels([x, y, z], filled)\n\nSee `~mpl_toolkits.mplot3d.axes3d.Axes3D.voxels`.\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')\n\n# Prepare some coordinates\nx, y, z = np.indices((8, 8, 8))\n\n# Draw cuboids in the top left and bottom right corners\ncube1 = (x < 3) & (y < 3) & (z < 3)\ncube2 = (x >= 5) & (y >= 5) & (z >= 5)\n\n# Combine the objects into a single boolean array\nvoxelarray = cube1 | cube2\n\n# Plot\nfig, ax = plt.subplots(subplot_kw={\"projection\": \"3d\"})\nax.voxels(voxelarray, edgecolor='k')\n\nax.set(xticklabels=[],\n yticklabels=[],\n zticklabels=[])\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.5" } }, "nbformat": 4, "nbformat_minor": 0 }