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,
Creates a new
plot curve, and callsset_datawith the other (keyword) arguments.- Parameters:
*args – Provide
xandy, justy, 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 withsquap.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 isFalse.dash_pattern (list, optional) – How the dashes are spaced. For example, if
dash_patternis[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. Settingdash_patternwill also automatically setdashedtoTrue. 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-Nvalues of0or1(Nbeing the length ofxandy). Values of1indicate that the respective point will be connected to the next.
Defaults to
"auto".gradient (
QGradient, optional) – gradient of the line. Usesquap.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. Whenstyleof the gradient is set to"horizontal"or"vertical", or"radial"without providingposition, the bounds of the gradient will be automatically determined whenset_datais called, which can decrease performance. So, specifypositionfor optimal performance. Default isNone.line_style (optional, str) – todo: some presets for simplicity,
lsis also allowed instead ofline_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 ofdownsamplesamples. This method is fastest and least accurate. Length of datasets will be divided by downsample"mean": Downsample by taking the mean ofdownsamplesamples. Length of datasets will be divided bydownsample."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
NaNvalues. If set toTrue, andNaNvalues exist, unpredictable behavior will occur. The data may not be displayed or the plot may take a significant performance hit. Defaults toFalse.**kwargs – Can contain aliases and the following: -
x: You can providexas keyword argument as well. -y: You can provideyas 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,
Creates a new
scatter curve, and callsset_datawith the other arguments. If bothxandyare provided, you can set them together usingscatter(x, y, ...). If onlyyis provided usingscatter(y, ...),xis set as the index ofy.xandycan also be passed as keyword arguments by doingscatter(x=x, ...),scatter(y=y)orscatter(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
xandy, justy, 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
xandy.size (int or list of int) – The size of the scatter plot points. Also accepted as
s. Default is7.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. IfFalse, size is specified in data coordinates. Defaults toTrue.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 ofdownsamplesamples. This method is fastest and least accurate. Length of datasets will be divided by downsample"mean": Downsample by taking the mean ofdownsamplesamples. Length of datasets will be divided bydownsample."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 providexas keyword argument as well. -y: You can provideyas 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,
Creates a new
errorbar curve, and callsset_datawith the other (keyword) arguments.- Parameters:
*args – For providing
xandy. (Can also be provided as keyword arguments).xandymust be the same length. If only one argument is provided, it is interpreted asyandxis set to the index ofy.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, andx_err[i, 1]is the error on the right at each pointi.
Defaults to
None.y_err – Same as
x_errbut fory.color (ColorType) – Color of the line and errorbars. Default is
"y"(yellow). Can also be a gradient (seesquap.get_gradient()). If the color of the line and of the errorbar should be different, provide bothline_coloranderrorbar_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 seedash_pattern). Defaults toFalse.dash_pattern (list, optional) – How the dashes are spaced. For example, if
dash_patternis[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. Settingdash_patternwill also automatically setdashedtoTrue. 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-Nvalues of0or1(Nbeing the length ofxandy). Values of1indicate 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. Usesquap.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. Whenstyleof the gradient is set to"horizontal"or"vertical", or"radial"without providingposition, the bounds of the gradient will be automatically determined whenset_datais called, which can decrease performance. So, specifypositionfor 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 ofdownsamplesamples. This method is fastest and least accurate. Length of datasets will be divided by downsample"mean": Downsample by taking the mean ofdownsamplesamples. Length of datasets will be divided bydownsample."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
NaNvalues. If set toTrue, andNaNvalues exist, unpredictable behavior will occur. The data may not be displayed or the plot may take a significant performance hit. Defaults toFalse.**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 justPlotCurve.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,
Creates an
imageat locationlocation. This image consists of equally spaced pixels, colored according todataandcmap. 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, between0and1.(Nx, Ny, 4): array of colors, between0and1, with alpha values.(Nx, Ny): array of values between0and1, corresponding to grayscale or colors corresponding tocmapif 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 fromsquap.get_cmap()ordataargument accepted bysquap.get_cmap().auto_levels (bool, optional) – todo: describe
levels (optional) – todo: describe
axis_order (bool, optional) – Whether the ordering of the pixels listed in
datais"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: