Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitd50bf9a

Browse files
committed
DOC: add gallery example
1 parent29e3a8d commitd50bf9a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
========================================
3+
3D Histogram with hexagonal bins
4+
========================================
5+
6+
Demonstrates visualising a 3D density map of data using hexagonal tessellation.
7+
"""
8+
9+
importmatplotlib.pyplotasplt
10+
importnumpyasnp
11+
12+
frommatplotlib.cbookimporthexbin
13+
14+
# Fixing random state for reproducibility
15+
np.random.seed(42)
16+
17+
# Generate samples from mltivariate Gaussian
18+
# Parameters
19+
mu= (0,0)
20+
sigma= ([0.8,0.3],
21+
[0.3,0.5])
22+
n=10_000
23+
gridsize=15
24+
# draw samples
25+
xy=np.random.multivariate_normal(mu,sigma,n)
26+
# histogram samples with hexbin
27+
xyz, (xmin,xmax), (ymin,ymax), (nx,ny)=hexbin(*xy.T,gridsize=gridsize,
28+
mincnt=3)
29+
# compute bar cross section size
30+
dxy=np.array([(xmax-xmin)/nx, (ymax-ymin)/ny/np.sqrt(3)])*0.95
31+
32+
# plot
33+
fig,ax=plt.subplots(subplot_kw={'projection':'3d'})
34+
ax.hexbar3d(*xyz,dxy,cmap='plasma')
35+
ax.set(xlabel='x',ylabel='y',zlabel='z')
36+
37+
plt.show()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp