Plotting Functions#

All the customisation options for a curve generated from squap.plot(), squap.scatter() and squap.errorbar() are shown in this example: Plot Customisation.

squap.plot(
*args,
color='y',
width=1,
dashed=False,
dash_pattern=None,
connect='auto',
gradient=None,
line_style=None,
antialias=True,
auto_downsample=False,
downsample=1,
downsample_method='mean',
skip_finite_check=False,
**kwargs,
)[source]#

Creates a new plot curve, and calls set_data with the other (keyword) arguments.

Parameters:
  • *args – Provide x and y, just y, or no data at all. Data can also be passed as keyword arguments.

  • color (ColorsType) – The color of the line. Default is "y" (yellow). Can also be a gradient (created with squap.get_gradient()).

  • width (int) – Width of the plot line. Default is 1.

  • dashed (bool) – If True, draws a dashed line between the points (for more options see dash_pattern). Default is False.

  • dash_pattern (list, optional) – How the dashes are spaced. For example, if dash_pattern is [16, 16, 4, 16], the pattern will be: one dash of 16 pixels long, then a space of 16 pixels long, then a dash of 4 pixels long and then a dash of 16 pixels long. This pattern is then repeated. This should be a list with a length that is an integer multiple of 2. Setting dash_pattern will also automatically set dashed to True. Defaults to [16, 16].

  • connect (str or np.ndarray) –

    Can be one of the following options:

    • "all": Connects all points.

    • "pairs": Generates lines between every other point.

    • "finite": Creates a break when a nonfinite points is encountered.

    • "auto": This will normally use "all", but if any nonfinite data points are detected, it will automatically switch to "finite".

    • ndarray - N values of 0 or 1 (N being the length of x and y). Values of 1 indicate that the respective point will be connected to the next.

    Defaults to "auto".

  • gradient (QGradient, optional) – gradient of the line. Use squap.get_gradient() to get the gradient. The gradient can be seen as a 2D image of a gradient which appears at each pixel that lies on the line. When style of the gradient is set to "horizontal" or "vertical", or "radial" without providing position, the bounds of the gradient will be automatically determined when set_data is called, which can decrease performance. So, specify position for optimal performance. Default is None.

  • line_style (optional, str) – todo: some presets for simplicity, ls is also allowed instead of line_style.

  • downsample (int) – Reduce the number of samples displayed by the given factor. Default is 1 (no downsampling).

  • downsample_method (str) –

    Can be one of the following options:

    • "subsample": Downsample by taking the first of downsample samples. This method is fastest and least accurate. Length of datasets will be divided by downsample

    • "mean": Downsample by taking the mean of downsample samples. Length of datasets will be divided by downsample.

    • "peak": Downsample by drawing a saw wave that follows the min and max of the original data. This method produces the best visual representation of the data but is slower. Length of dataset will stay the same.

    Defaults to "mean".

  • auto_downsample (bool) – Can increase performance by not drawing one pixel multiple times, but is slower for less data. Defaults to False.

  • antialias (bool) – Antialiasing can be disabled for a minor performance increase. Default is True.

  • skip_finite_check (bool) – Optimization flag that can speed up plotting by not checking and compensating for NaN values. If set to True, and NaN values exist, unpredictable behavior will occur. The data may not be displayed or the plot may take a significant performance hit. Defaults to False.

  • **kwargs – Can contain aliases and the following: - x: You can provide x as keyword argument as well. - y: You can provide y as keyword argument as well.

Returns:

The generated curve.

Return type:

PlotCurve

squap.scatter(
*args,
color='y',
size=7,
edge_width=-1,
edge_color='white',
pixel_mode=True,
downsample=1,
downsample_method='mean',
auto_downsample=False,
antialias=True,
**kwargs,
)[source]#

Creates a new scatter curve, and calls set_data with the other arguments. If both x and y are provided, you can set them together using scatter(x, y, ...). If only y is provided using scatter(y, ...), x is set as the index of y. x and y can also be passed as keyword arguments by doing scatter(x=x, ...), scatter(y=y) or scatter(x=x, y=y, ...). Furthermore, you can include additional keyword arguments such as color and size to customize the appearance of the curve.

Parameters:
  • *args – Provide x and y, just y, or no data at all. Data can also be passed as keyword arguments.

  • color (ColorType) – the color of the points. See ColorsType for allowed values. If a list of colors is passed, it should be the same length as x and y.

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

  • edge_width (int or list of int) – Width of the edge around each point. Default is -1 (no edge).

  • edge_color (ColorsType) – Color of the edge around each point. Default is white.

  • 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.

  • downsample (int) – Reduce the number of samples displayed by the given factor. Default is 1 (no downsampling).

  • downsample_method (str) –

    Can be one of the following options:

    • "subsample": Downsample by taking the first of downsample samples. This method is fastest and least accurate. Length of datasets will be divided by downsample

    • "mean": Downsample by taking the mean of downsample samples. Length of datasets will be divided by downsample.

    • "peak": Downsample by drawing a saw wave that follows the min and max of the original data. This method produces the best visual representation of the data but is slower. Length of dataset will stay the same.

    Defaults to "mean".

  • auto_downsample (bool) – Can increase performance by not drawing one pixel multiple times, but is slower for less data. Defaults to False.

  • antialias (bool) – Antialiasing can be disabled for a minor performance increase. Default is True.

  • kwargs – Can contain the following: - x: You can provide x as keyword argument as well. - y: You can provide y as keyword argument as well.

Returns:

The generated curve.

Return type:

PlotCurve

squap.errorbar(
*args,
x_err=None,
y_err=None,
color='y',
width=1,
errorbar_width=1,
beam_size=0,
dashed=False,
dash_pattern=None,
connect='auto',
gradient=None,
line_style=None,
antialias=True,
auto_downsample=False,
downsample=1,
downsample_method='mean',
skip_finite_check=False,
**kwargs,
)[source]#

Creates a new errorbar curve, and calls set_data with the other (keyword) arguments.

Parameters:
  • *args – For providing x and y. (Can also be provided as keyword arguments). x and y must be the same length. If only one argument is provided, it is interpreted as y and x is set to the index of y.

  • x_err

    Size of the errorbar at each x value. Can be the following types:

    • None: No error in the x-direction.

    • float: x-error at all points.

    • Iterable of same size as x: x-error at each point.

    • Iterable of size (Nx, 2): x_err[i, 0] is the error on the left at each point, and x_err[i, 1] is the error on the right at each point i.

    Defaults to None.

  • y_err – Same as x_err but for y.

  • color (ColorType) – Color of the line and errorbars. Default is "y" (yellow). Can also be a gradient (see squap.get_gradient()). If the color of the line and of the errorbar should be different, provide both line_color and errorbar_color.

  • width (int) – Width of the plot line. Default is 1. Does not affect the width of the errorbars.

  • errorbar_width (int) – Width of the errorbar lines. Default is 1.

  • beam_size (float) – Size of the bars at the ends of the errorbar lines. Default is 0.

  • dashed (bool) – If True, draws a dashed line between the points (for more options see dash_pattern). Defaults to False.

  • dash_pattern (list, optional) – How the dashes are spaced. For example, if dash_pattern is [16, 16, 4, 16], the pattern will be: one dash of 16 pixels long, then a space of 16 pixels long, then a dash of 4 pixels long and then a dash of 16 pixels long. This pattern is then repeated. This should be a list with a length that is an integer multiple of 2. Setting dash_pattern will also automatically set dashed to True. Defaults to [16, 16].

  • connect (str or np.ndarray) –

    Can be one of the following options:

    • "all": Connects all points.

    • "pairs": Generates lines between every other point.

    • "finite": Creates a break when a nonfinite points is encountered.

    • "auto": This will normally use "all", but if any nonfinite data points are detected, it will automatically switch to "finite".

    • ndarray - N values of 0 or 1 (N being the length of x and y). Values of 1 indicate that the respective point will be connected to the next.

    Defaults to "auto".

  • line_style (str, optional) – todo: some presets for simplicity, ls is also allowed instead of line_style.

  • gradient (QGradient, optional) – gradient of the line. Use squap.get_gradient() to get the gradient. The gradient can be seen as a 2D image of a gradient which appears at each pixel that lies on the line. When style of the gradient is set to "horizontal" or "vertical", or "radial" without providing position, the bounds of the gradient will be automatically determined when set_data is called, which can decrease performance. So, specify position for optimal performance.

  • downsample (int) – Reduce the number of samples displayed by the given factor. Default is 1 (no downsampling).

  • downsample_method (str) –

    Can be one of the following options:

    • "subsample": Downsample by taking the first of downsample samples. This method is fastest and least accurate. Length of datasets will be divided by downsample

    • "mean": Downsample by taking the mean of downsample samples. Length of datasets will be divided by downsample.

    • "peak": Downsample by drawing a saw wave that follows the min and max of the original data. This method produces the best visual representation of the data but is slower. Length of dataset will stay the same.

    Defaults to "mean".

  • auto_downsample (bool) – Can increase performance by not drawing one pixel multiple times, but is slower for less data. Defaults to False.

  • antialias (bool) – Antialiasing can be disabled for a minor performance increase. Default is True.

  • skip_finite_check (bool) – Optimization flag that can speed up plotting by not checking and compensating for NaN values. If set to True, and NaN values exist, unpredictable behavior will occur. The data may not be displayed or the plot may take a significant performance hit. Defaults to False.

  • **kwargs – Can contain the following: - x: You can provide x as keyword argument as well. - y: You can provide y as keyword argument as well. - line_color: For seperating errorbar and line color. - error_color: For seperating errorbar and line color. - line_width: For seperating errorbar and line width. - error_width: For seperating errorbar and line width.

Returns:

The generated curve. The errorbar curve is technically located at ErrorbarCurve, but everything can be set with just PlotCurve.set_data().

Return type:

PlotCurve

squap.imshow(
data=None,
location=None,
cmap=None,
auto_levels=False,
levels=None,
axis_order='row-major',
border_color=None,
**kwargs,
)[source]#

Creates an image at location location. This image consists of equally spaced pixels, colored according to data and cmap. This function hasn’t been tested thoroughly

Parameters:
  • data (np.ndarray, optional) –

    Array containing data to be shown. Can be shape:

    • (Nx, Ny, 3): array of colors, between 0 and 1.

    • (Nx, Ny, 4): array of colors, between 0 and 1, with alpha values.

    • (Nx, Ny): array of values between 0 and 1, corresponding to grayscale or colors corresponding to cmap if it is provided.

  • location (tuple, optional) – Location of the image. (location[0], location[1]) is the bottom left coordinate, and (location[2], location[3]) is the top right coordinate.

  • cmap (Any) – Colormap from squap.get_cmap() or data argument accepted by squap.get_cmap().

  • auto_levels (bool, optional) – todo: describe

  • levels (optional) – todo: describe

  • axis_order (bool, optional) – Whether the ordering of the pixels listed in data is "row-major" or "col-major". Todo: test if it does anything.

  • border_color (ColorType, optional) – Color of the border around the image. Defaults to None, meaning no border.

  • todo – border thickness?

Returns:

The created image curve.

Return type:

ImageCurve