Widgets And Objects For 3D Plots#

All functions for creating 3D plots can also be done through a SubplotWidget3D object. This is useful for 3D subplots, or just if you prefer working with widgets and not having to write _3D after all your functions. squap.make_3D() can be used to initialse a SubplotWidget3D object, or turn an existing plot object from squap.subplots() into a 3D plot.

class squap.widgets.plot_widget_3D.SubplotWidget3D(row, col, **kwargs)[source]#

Widget for 3D plots. Obtain from squap.make_3D()

set_camera(
x_offset=None,
y_offset=None,
z_offset=None,
distance=None,
azimuth=None,
elevation=None,
fov=None,
)[source]#

Sets the camera offset, distance, rotation and fov using the given arguments. distance, azimuth and elevation act like polar coordinates around the origin, and x_offset, y_offset and z_offset determine the position of this origin. Use squap.align_camera() to experiment with these values and find the correct ones.

Parameters:
  • x_offset (float, optional) – New x offset of the origin.

  • y_offset (float, optional) – New y offset of the origin.

  • z_offset (float, optional) – New z offset of the origin.

  • distance (float, optional) – New distance between the camera position and the origin.

  • azimuth (float, optional) – Angle of rotation horizontally around the origin.

  • elevation (float, optional) – Angle of rotation vertically about the origin.

  • fov (float, optional) – Field of view.

scatter(
x=None,
y=None,
z=None,
pos=None,
color='y',
size=4,
pixel_mode=True,
**kwargs,
)[source]#

Creates a new scatter plot item. Use either x, y and z or pos to set the coordinates of the points.

Parameters:
  • x (np.ndarray, optional) – New x-locations of each point. Defaults to None, which means the data will be initialised with pos, or it will be initialised later.

  • y (np.ndarray, optional) – New y-locations of each point. Defaults to None, which means the data will be initialised with pos, or it will be initialised later.

  • z (np.ndarray, optional) – New z-locations of each point. Defaults to None, which means the data will be initialised with pos, or it will be initialised later.

  • pos (np.ndarray, optional) – Shape (N, 3) (array) of floats specifying point locations. Can be used instead of x, y and z.

  • color (ColorsType) – Changes the color of the points. See ColorsType for allowed values.

  • size (int or list of int) – The size of the scatter plot points. Also accepted as s. Default is 4.

  • pixel_mode (bool) – Whether to fix the size of each point. If True, size is specified in pixels. If False, size is specified in data coordinates. Defaults to True.

set_zoom_rate(
new_rate=1.003,
)[source]#

Sets the rate at which you zoom when the plot is zoomed after it has been created. Starts off at 1.003.

add_grid(
diagonal,
spacing=1,
)[source]#

Adds a grid that lies on or parallel to one of the planes.

Parameters:
  • diagonal (tuple of float) – A tuple of two coordinates that span the diagonal of a rectangle that lies on or parallel to the xy, yz, or zx plane.

  • spacing (float) – Spacing between the grid lines. Defaults to 1.

Returns:

The created grid.

Return type:

GLGridItem

add_grids(
size,
spacing=1,
)[source]#

Adds square grids on the xy, yz and zx planes, spanning from size[0] to size[1].

Parameters:
  • size (tuple of float) – the size of each grid.

  • spacing (float) – Spacing between the grid lines. Defaults to 1.

Returns:

The created grids.

Return type:

list of GLGridItem