scatter_3d

ssapy.plotUtils.scatter_3d(x, y=None, z=None, cs=None, xlabel='x', ylabel='y', zlabel='z', cbar_label='', dotsize=1, colorsMap='jet', title='', save_path=False)[source][source]

Create a 3D scatter plot with optional color mapping.

Parameters: - x (numpy.ndarray): Array of x-coordinates or a 2D array with shape (n, 3) representing the x, y, z coordinates. - y (numpy.ndarray, optional): Array of y-coordinates. Required if x is not a 2D array with shape (n, 3). Default is None. - z (numpy.ndarray, optional): Array of z-coordinates. Required if x is not a 2D array with shape (n, 3). Default is None. - cs (numpy.ndarray, optional): Array of values for color mapping. Default is None. - xlabel (str, optional): Label for the x-axis. Default is ‘x’. - ylabel (str, optional): Label for the y-axis. Default is ‘y’. - zlabel (str, optional): Label for the z-axis. Default is ‘z’. - cbar_label (str, optional): Label for the color bar. Default is an empty string. - dotsize (int, optional): Size of the dots in the scatter plot. Default is 1. - colorsMap (str, optional): Colormap to use for the color mapping. Default is ‘jet’. - title (str, optional): Title of the plot. Default is an empty string. - save_path (str, optional): File path to save the plot. If not provided, the plot is not saved. Default is False.

Returns: - fig (matplotlib.figure.Figure): The figure object. - ax (matplotlib.axes._subplots.Axes3DSubplot): The 3D axis object.

This function creates a 3D scatter plot with optional color mapping based on the values provided in cs. The plot can be customized with axis labels, title, and colormap. The plot can also be saved to a specified file path.

Example usage: ``` import numpy as np from your_module import scatter_3d

# Example data x = np.random.rand(100) y = np.random.rand(100) z = np.random.rand(100) cs = np.random.rand(100)

scatter_3d(x, y, z, cs, xlabel=’X-axis’, ylabel=’Y-axis’, zlabel=’Z-axis’, cbar_label=’Color Scale’, title=’3D Scatter Plot’) ```