{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Scatter 3D\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\nimport matplotlib.pyplot as plt\n\n\ndef randrange(n, vmin, vmax):\n return (vmax - vmin) * np.random.rand(n) + vmin\n\n\nfig = plt.figure()\nax = fig.add_subplot(111, projection=\"3d\")\nn = 100\nfor c, m, zl, zh in [(\"r\", \"o\", -50, -25), (\"b\", \"^\", -30, -5)]:\n xs = randrange(n, 23, 32)\n ys = randrange(n, 0, 100)\n zs = randrange(n, zl, zh)\n ax.scatter(xs, ys, zs, c=c, marker=m)\n\nax.set_xlabel(\"X Label\")\nax.set_ylabel(\"Y Label\")\nax.set_zlabel(\"Z Label\")\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.8.10" } }, "nbformat": 4, "nbformat_minor": 0 }