{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# hist2d(x, y)\nMake a 2D histogram plot.\n\nSee `~matplotlib.axes.Axes.hist2d`.\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-nogrid')\n\n# make data: correlated + noise\nnp.random.seed(1)\nx = np.random.randn(5000)\ny = 1.2 * x + np.random.randn(5000) / 3\n\n# plot:\nfig, ax = plt.subplots()\n\nax.hist2d(x, y, bins=(np.arange(-3, 3, 0.1), np.arange(-3, 3, 0.1)))\n\nax.set(xlim=(-2, 2), ylim=(-3, 3))\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.2" } }, "nbformat": 4, "nbformat_minor": 0 }