8000 Merge pull request #24200 from meeseeksmachine/auto-backport-of-pr-24… · matplotlib/matplotlib@2ca3410 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2ca3410

Browse files
authored
Merge pull request #24200 from meeseeksmachine/auto-backport-of-pr-24193-on-v3.6.x
Backport PR #24193 on branch v3.6.x (DOC: Explain gridsize in hexbin())
2 parents 61a7860 + 5aed376 commit 2ca3410

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