MCPcopy
hub / github.com/tum-pbs/PhiFlow / plot

Method plot

phi/vis/_matplotlib/_matplotlib_plots.py:402–418  ·  view source on GitHub ↗
(self, data: Field, figure, subplot, space: Box, min_val: float, max_val: float, show_color_bar: bool, color: Tensor, alpha: Tensor, err: Tensor)

Source from the content-addressed store, hash-verified

400 return data.is_grid and channel(data).volume == 1 and data.spatial_rank == 3
401
402 def plot(self, data: Field, figure, subplot, space: Box, min_val: float, max_val: float, show_color_bar: bool, color: Tensor, alpha: Tensor, err: Tensor):
403 dims = space.vector.item_names
404 xyz = StaggeredGrid(lambda x: x, math.extrapolation.BOUNDARY, data.geometry.bounds, data.resolution).staggered_tensor().numpy(dims + ('vector',))[:-1, :-1, :-1, :]
405 xyz = xyz.reshape(-1, 3)
406 values = data.values.numpy(dims).flatten()
407 if wrap(color == 'cmap').all:
408 color = 0
409 col = matplotlib.colors.to_rgba(_plt_col(color))
410 colors = np.zeros_like(values)[..., None] + col
411 norm_values = (values - min_val) / (max_val - min_val)
412 size = len(values) ** .3333
413 exponent = size / 15
414 alpha = float(alpha) * norm_values ** exponent
415 colors[..., -1] *= alpha
416 size = [data.dx.numpy()] * len(xyz)
417 cubes = plotCubeAt(xyz, size, colors)
418 subplot.add_collection3d(cubes)
419
420
421def cuboid_data(min_xyz: np.ndarray, size=(1, 1, 1)):

Callers

nothing calls this directly

Calls 5

StaggeredGridFunction · 0.90
_plt_colFunction · 0.85
plotCubeAtFunction · 0.85
numpyMethod · 0.80
staggered_tensorMethod · 0.80

Tested by

no test coverage detected