FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

DOC: Explain gridsize in hexbin() by timhoffm · Pull Request #24193 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
26 changes: 25 additions & 1 deletion lib/matplotlib/axes/_axes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4715,7 +4715,31 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
the hexagons are approximately regular.

Alternatively, if a tuple (*nx*, *ny*), the number of hexagons
in the *x*-direction and the *y*-direction.
in the *x*-direction and the *y*-direction. In the
*y*-direction, counting is done along vertically aligned
hexagons, not along the zig-zag chains of hexagons; see the
following illustration.

.. plot::

import numpy
import matplotlib.pyplot as plt

np.random.seed(19680801)
n= 300
x = np.random.standard_normal(n)
y = np.random.standard_normal(n)

fig, ax = plt.subplots(figsize=(4, 4))
h = ax.hexbin(x, y, gridsize=(5, 3))
hx, hy = h.get_offsets().T
ax.plot(hx[24::3], hy[24::3], 'ro-')
ax.plot(hx[-3:], hy[-3:], 'ro-')
ax.set_title('gridsize=(5, 3)')
ax.axis('off')

To get approximately regular hexagons, choose
:math:`n_x = \\sqrt{3}\\,n_y`.

bins : 'log' or int or sequence, default: None
Discretization of the hexagon values.
Expand Down

Back | FazBrowse Home | New Git URL