def test_doc_035(self): import numpy as np # Define the 2 independent variables phi, theta = np.meshgrid(np.linspace(0, 2 * np.pi, 1024), np.linspace(0, np.pi, 1024)) # Calculate the x, y, z values to form a sphere x = np.cos(phi) * np.sin(theta) y = np.sin(phi) * np.sin(theta) z = np.cos(theta) # You can play around with this. The coordinates must be zipped # together into one array with ``shape[-1] == 2``, hence the # ``vpl.zip_axes``. And must be between 0 and 1, hence the ``% 1.0``. texture_coords = (vpl.zip_axes(phi * 3, theta * 5) / np.pi) % 1.0 # Pick an image to use. There is a picture of a shark here if you # don't have one available. path = vpl.data.ICONS["Right"] texture_map = vpl.TextureMap(path, interpolate=True) # You could convert ``texture_coords`` to ``colors`` now using. # colors = texture_map(texture_coords) # then pass ``colors`` as the `scalars` argument instead. vpl.surface(x, y, z, scalars=texture_coords, texture_map=texture_map)
def test_surface(): thi, theta = np.meshgrid(np.linspace(0, 2 * np.pi, 100), np.linspace(0, np.pi, 50)) x = np.cos(thi) * np.sin(theta) y = np.sin(thi) * np.sin(theta) z = np.cos(theta) vpl.surface(x, y, z, scalars=x.ravel())
def test_doc_09(self): import vtkplotlib as vpl import numpy as np phi, theta = np.meshgrid(np.linspace(0, 2 * np.pi, 1024), np.linspace(0, np.pi, 1024)) x = np.cos(phi) * np.sin(theta) y = np.sin(phi) * np.sin(theta) z = np.cos(theta) vpl.surface(x, y, z)
def test_texture(): phi, theta = np.meshgrid(np.linspace(0, 2 * np.pi, 1024), np.linspace(0, np.pi, 1024)) x = np.cos(phi) * np.sin(theta) y = np.sin(phi) * np.sin(theta) z = np.cos(theta) self = vpl.surface(x, y, z, fig=None) path = vpl.data.ICONS["Right"] self.polydata.texture_map = vpl.TextureMap(path, interpolate=True) self.colors = (vpl.zip_axes(phi * 3, theta * 5) / np.pi) % 1. self.connect() vpl.gcf().add_plot(self)