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

Method plot

phi/vis/_matplotlib/_matplotlib_plots.py:448–467  ·  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

446 return data.spatial_rank == 2 and 'vector' in channel(data)
447
448 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):
449 dims = space.vector.item_names
450 vector = data.geometry.shape['vector']
451 channels = channel(data).without('vector')
452 data = only_stored_elements(data)
453 for idx in channels.meshgrid(names=True):
454 c_data = data[idx]
455 x, y = reshaped_numpy(c_data.center[dims], [vector, c_data.shape.without('vector')])
456 u, v = reshaped_numpy(c_data.values.vector[dims], [vector, c_data.shape.without('vector')])
457 color_i = color[idx]
458 if wrap(color[idx] == 'cmap').all:
459 col = _next_line_color(subplot, kind='collections') # ToDo
460 elif color[idx].shape:
461 col = [_plt_col(c) for c in color_i.numpy(c_data.shape.non_channel).reshape(-1)]
462 else:
463 col = _plt_col(color[idx])
464 alphas = reshaped_numpy(alpha, [c_data.shape.without('vector')])
465 subplot.quiver(x, y, u, v, color=col, units='xy', scale=1, alpha=alphas, label=index_label(idx) if channels.volume > 1 else None)
466 if channels and not has_legend_like([index_label(idx_n) for idx_n in channels.meshgrid(names=True)], figure):
467 subplot.legend()
468
469
470class VectorCloud3D(Recipe):

Callers

nothing calls this directly

Calls 7

only_stored_elementsFunction · 0.90
index_labelFunction · 0.90
_next_line_colorFunction · 0.85
_plt_colFunction · 0.85
has_legend_likeFunction · 0.85
withoutMethod · 0.80
numpyMethod · 0.80

Tested by

no test coverage detected