8000 Backport PR #24193: DOC: Explain gridsize in hexbin() · matplotlib/matplotlib@5aed376 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5aed376

Browse files
oscargusmeeseeksmachine
authored andcommitted
Backport PR #24193: DOC: Explain gridsize in hexbin()
1 parent 075418d commit 5aed376

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4681,7 +4681,31 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
46814681
the hexagons are approximately regular.
46824682
46834683
Alternatively, if a tuple (*nx*, *ny*), the number of hexagons
4684-
in the *x*-direction and the *y*-direction.
4684+
in the *x*-direction and the *y*-direction. In the
4685+
*y*-direction, counting is done along vertically aligned
4686+
hexagons, not along the zig-zag chains of hexagons; see the
4687+
following illustration.
4688+
4689+
.. plot::
4690+
4691+
import numpy
4692+
import matplotlib.pyplot as plt
4693+
4694+
np.random.seed(19680801)
4695+
n= 300
4696+
x = np.random.standard_normal(n)
4697+
y = np.random.standard_normal(n)
4698+
4699+
fig, ax = plt.subplots(figsize=(4, 4))
4700+
h = ax.hexbin(x, y, gridsize=(5, 3))
4701+
hx, hy = h.get_offsets().T
4702+
ax.plot(hx[24::3], hy[24::3], 'ro-')
4703+
ax.plot(hx[-3:], hy[-3:], 'ro-')
4704+
ax.set_title('gridsize=(5, 3)')
4705+
ax.axis('off')
4706+
4707+
To get approximately regular hexagons, choose
4708+
:math:`n_x = \\sqrt{3}\\,n_y`.
46854709
46864710
bins : 'log' or int or sequence, default: None
46874711
Discretization of the hexagon values.

0 commit comments

Comments
 (0)
0