histo_hexagonal.py 576 B

12345678910111213141516171819
  1. from vedo import Latex, show
  2. from vedo.pyplot import histogram
  3. import numpy as np
  4. N = 2000
  5. x = np.random.randn(N) * 1.0
  6. y = np.random.randn(N) * 1.5
  7. # hexagonal binned histogram:
  8. histo = histogram(x, y, bins=10, mode="hexbin", fill=True, cmap="terrain")
  9. # add a formula:
  10. f = r"f(x, y)=A \exp \left(-\left(\frac{\left(x-x_{o}\right)^{2}}"
  11. f += r"{2 \sigma_{x}^{2}}+\frac{\left(y-y_{o}\right)^{2}}"
  12. f += r"{2 \sigma_{y}^{2}}\right)\right)"
  13. formula = Latex(f, c="k", s=1.5)
  14. formula.rotate_x(90).rotate_z(90).pos([-4, -5, 2])
  15. show(histo, formula, axes=1, viewup="z").close()