Curves#

Each of the plot objects are represented by one of the curve objects listed below.

All the customisation options for a PlotCurve are shown in Plot Customisation.

class squap.widgets.curves.PlotCurve(
parent,
curve_type='plot',
*args,
**kwargs,
)[source]#
set_data(
x=None,
y=None,
**kwargs,
)[source]#

This function updates the data of a plot, scatter, or errorbar, curve. If both x and y are provided, you can set them together using set_data(x, y, ...). If either x or y is provided, you can set them individually, for example, set_data(x=x, ...) or set_data(y=y, ...). Furthermore, you can include additional keyword arguments such as color and width to customize the appearance of the curve.

Note

For scatter points, symbol_color is used for the color of points instead of color when the curve was not initialised as a scatter plot.

Parameters:
  • x – New x-locations of each point. Defaults to the previous value of x.

  • y – New y-locations of each point. Defaults to the previous value of y.

Keyword Arguments:
  • color (ColorsType) – Changes the color of the curve. For a scatter-plot this is equivalent to symbol_color, for a regular plot it is equivalent to line_color. colour or c is also allowed instead of color.

  • width (int) – Changes the width (in pixels) of the curve. w is also allowed instead of width.

  • line_color (ColorType) – Changes the color of the line. See ColorsType for allowed values. It can also be a gradient (created with squap.get_gradient()).

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

  • line_style (optional, str) – 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.

  • fill_level (float) – fills the area under the curve to this Y-value. When provided, either provide fill_color or fill_gradient.

  • fill_color (ColorType) – color of the filled area.

  • fill_gradient – gradient of the filled area.

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

  • symbol_size (int) – The size (in pixels) of each symbol. Can also be a list or array. s and size are also allowed instead of symbol_size.

  • symbol (str) – symbol to draw at each (x, y) location. Can be e.g.: "o" for circles (default), "t" for triangles, "s" for squares, "d" for diamonds. For all options see an example that I still have to make.

  • symbol_line_width (int) – the line width each symbol is drawn with, symbol_lw and slw are also allowed.

  • symbol_line_color (ColorsType) – Change the color of the line around each symbol, see ColorsType for allowed values. symbol_lc and slc are also allowed.

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

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

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

  • errorbar_color (ColorType) – Color of the errorbars. Default is "y" (yellow).

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

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

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

  • clip_to_view (bool) – If True, only data visible within the X range of the containing ViewBox is plotted. This can improve performance when plotting very large data sets where only a fraction of the data is visible at any time.

class squap.widgets.curves.ErrorbarCurve(
parent,
x_err=None,
y_err=None,
beam_size=0.0,
color='white',
width=1,
)[source]#

Is added to PlotCurve as attribute when an errorbar curve is initialised. Users probably will not interact with this object.

set_data(*args, **kwargs)[source]#

Used internally when plotting with an errorbar. Users will only interact with the PlotCurve.

class squap.widgets.curves.TextCurve(*args: Any, **kwargs: Any)[source]#
set_data(*args, **kwargs)[source]#

Updates an existing text object. Takes the same arguments and keyword arguments as squap.plot_text().

class squap.widgets.curves.InfLine(*args: Any, **kwargs: Any)[source]#
set_data(pos=None, **kwargs)[source]#

Updates an existing line object. Takes the same arguments and keyword arguments as squap.inf_dline().

class squap.widgets.curves.ImageCurve(*args: Any, **kwargs: Any)[source]#
set_data(data=None, **kwargs)[source]#

Updates an existing image object. Takes the same arguments and keyword arguments as squap.imshow().

class squap.widgets.curves.GridCurve(*args: Any, **kwargs: Any)[source]#
set_data(**kwargs)[source]#

Updates an existing grid object. Takes the same arguments and keyword arguments as squap.grid().