{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# scatter(x, y)\nA scatter plot of y vs. x with varying marker size and/or color.\n\nSee `~matplotlib.axes.Axes.scatter`.\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# make the data\nnp.random.seed(3)\nx = 4 + np.random.normal(0, 2, 24)\ny = 4 + np.random.normal(0, 2, len(x))\n# size and color:\nsizes = np.random.uniform(15, 80, len(x))\ncolors = np.random.uniform(15, 80, len(x))\n\n# plot\nfig, ax = plt.subplots()\n\nax.scatter(x, y, s=sizes, c=colors, vmin=0, vmax=100)\n\nax.set(xlim=(0, 8), xticks=np.arange(1, 8),\n ylim=(0, 8), yticks=np.arange(1, 8))\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 }