File: histo_2d_b.py

package info (click to toggle)
vedo 2025.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,404 kB
  • sloc: python: 64,792; javascript: 1,932; xml: 437; sh: 139; makefile: 6
file content (26 lines) | stat: -rw-r--r-- 559 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""Histogram of 2 variables as 3D bars"""
import numpy as np
from vedo import Points, show
from vedo.pyplot import histogram

n = 1000
x = np.random.randn(n)*1.5 + 60
y = np.random.randn(n)     + 70

histo = histogram(
    x, y,
    bins=(12, 10),
    cmap="summer",
    ztitle="Number of entries in bin",
    mode="3d",
    gap=0.0,
    zscale=0.4,  # rescale the z axis
    aspect=16/9,
)

print(histo.frequencies)

# Add also the original points on top
histo += Points(np.c_[x, y]).z(3).c("red5").point_size(4)

show(histo, __doc__, elevation=-80).close()