histo_1d_e.py 800 B

1234567891011121314151617181920212223
  1. """Plot a histogram of the distance of each point
  2. of a sphere to the oceans mesh. The distance is used to
  3. threshold the sphere and create continents."""
  4. from vedo import *
  5. from vedo.pyplot import histogram
  6. # Download the oceans mesh
  7. oceans = Mesh(dataurl + "oceans.vtk").c("blue9")
  8. size = oceans.average_size()
  9. # Create a sphere and compute the distance to the oceans mesh
  10. sphere = IcoSphere(subdivisions=5).scale(size*1.01)
  11. dists = sphere.distance_to(oceans)
  12. # Create a histogram of the distance
  13. histo = histogram(dists, logscale=True, c="gist_earth")
  14. histo+= Arrow2D([200,1], [200,0]).z(1).c("red5")
  15. # Threshold the sphere to create continents
  16. continents = sphere.threshold("Distance", above=20.0)
  17. continents.cmap("gist_earth").linewidth(1)
  18. show(oceans, continents, histo.clone2d(), __doc__)