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,
- set_data(
- x=None,
- y=None,
- **kwargs,
This function updates the data of a
plot,scatter, orerrorbar, curve. If bothxandyare provided, you can set them together usingset_data(x, y, ...). If eitherxoryis provided, you can set them individually, for example,set_data(x=x, ...)orset_data(y=y, ...). Furthermore, you can include additional keyword arguments such ascolorandwidthto customize the appearance of the curve.Note
For scatter points,
symbol_coloris used for the color of points instead ofcolorwhen 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
colorof the curve. For a scatter-plot this is equivalent tosymbol_color, for a regular plot it is equivalent toline_color.colourorcis also allowed instead ofcolor.width (int) – Changes the width (in pixels) of the curve.
wis also allowed instead ofwidth.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 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].line_style (optional, str) – todo: some presets for simplicity,
lsis also allowed instead ofline_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.fill_level (float) – fills the area under the curve to this Y-value. When provided, either provide
fill_colororfill_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
xandy.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_lwandslware also allowed.symbol_line_color (ColorsType) – Change the color of the line around each symbol, see ColorsType for allowed values.
symbol_lcandslcare also allowed.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.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.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-Nvalues of0or1(Nbeing the length ofxandy). Values of1indicate 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 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.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,
Is added to PlotCurve as attribute when an errorbar curve is initialised. Users probably will not interact with this object.
- 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().