[ Web Proxy ]
URL:
Viewing: https://matplotlib.org/gallery/mplot3d/../misc/../units/../../plot_types/basic/../stats/hist2d.html [Back]  [Original]

hist2d(x, y) — Matplotlib 3.11.2 documentation
Back to top
Search the docs ...:

hist2d(x, y)#

Make a 2D histogram plot.

See hist2d.

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()

Gallery generated by Sphinx-Gallery


Web Proxy Viewer  |  New URL  |  Original Page