v3d.plotly.to_xyz_dict#

visu3d.plotly.to_xyz_dict(arr: etils.enp.array_types.typing.Array, *, pattern: str = '{}', names: str | collections.abc.Sequence[str] = 'xyz', axis: int = -1) Dict[str, numpy.ndarray | str | int | bool | float][source]#

Convert np.array to xyz dict.

Useful to create plotly kwargs from numpy arrays.

Example:

to_xyz_dict(np.zeros((1, 3))) == {'x': [0], 'y': [0], 'z': [0]}
to_xyz_dict(
  [0, 1, 2],
  pattern='axis_{}'
  names='uvw',
) == {'axis_u': 0, 'axis_v': 1, 'axis_w': 2}
Parameters:
  • arr – Array to convert

  • pattern – Pattern to use for the axis names

  • names – Names of the axis (default to ‘x’, ‘y’, ‘z’)

  • axis – Axis containing the x, y, z coordinates to dispatch

Returns:

The dict containing plotly kwargs.

Return type:

xyz_dict