File: histo_1d_e.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 (23 lines) | stat: -rw-r--r-- 800 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
"""Plot a histogram of the distance of each point 
of a sphere to the oceans mesh. The distance is used to
threshold the sphere and create continents."""
from vedo import *
from vedo.pyplot import histogram

# Download the oceans mesh
oceans = Mesh(dataurl + "oceans.vtk").c("blue9")
size = oceans.average_size()

# Create a sphere and compute the distance to the oceans mesh
sphere = IcoSphere(subdivisions=5).scale(size*1.01)
dists = sphere.distance_to(oceans)

# Create a histogram of the distance
histo = histogram(dists, logscale=True, c="gist_earth")
histo+= Arrow2D([200,1], [200,0]).z(1).c("red5")

# Threshold the sphere to create continents
continents = sphere.threshold("Distance", above=20.0)
continents.cmap("gist_earth").linewidth(1)

show(oceans, continents, histo.clone2d(), __doc__)