GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Plot types
  • User guide
  • Tutorials
  • Examples
  • Reference
  • Contribute
  • Releases
  • Gitter
  • Discourse
  • GitHub
  • Pairwise data
  • plot(x, y)
  • scatter(x, y)
  • bar(x, height)

This view

  • Original page
  • New address

GeezerVison is showing matplotlib.org — hist2d(x, y) — Matplotlib 3.11.2 documentation

Note

Go to the end to download the full example code.

hist2d(x, y)#

Make a 2D histogram plot.

See hist2d.

hist2d
import matplotlib.pyplot as plt
import numpy as np

plt.style.use('_mpl-gallery-nogrid')

# make data: correlated + noise
np.random.seed(1)
x = np.random.randn(5000)
y = 1.2 * x + np.random.randn(5000) / 3

# plot:
fig, ax = plt.subplots()

ax.hist2d(x, y, bins=(np.arange(-3, 3, 0.1), np.arange(-3, 3, 0.1)))

ax.set(xlim=(-2, 2), ylim=(-3, 3))

plt.show()

Download Jupyter notebook: hist2d.ipynb

Download Python source code: hist2d.py

Download zipped: hist2d.zip

Gallery generated by Sphinx-Gallery

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.