XYPicker#

class tangles.util.ui.XYPicker(ax, sel_callback, xrange, yrange, xticks=10, yticks=10, continuous_update=False, draw_custom_picker=None)#

Interactive plot, which allows the user to pick different points from a two-dimensional plot and interactively see the results. Based on the matplotlib library.

Parameters#

ax

A matplotlib axis object.

sel_callback

A function which takes a x and a y coordinate and optionally another object. The function is called whenever the user makes a selection and is given the x- and y-coordinates which the user selected. If you want the function to take an object you have to set the callback_object attribute of the XYPicker instance.

xrangelist

Specify an interval of the form [min_x_value, max_x_value].

yrangelist

Specify an interval of the form [min_y_value, max_y_value].

xticksint, list, np.ndarray or range

Either a list, np.ndarray or range containing the ticks of the x-axis or an int determining the number of ticks on the x-axis. Defaults to 10.

yticksint, list, np.ndarray or range

Either a list, np.ndarray or range containing the ticks of the y-axis or an int determining the number of ticks on the y-axis. Defaults to 10.

continuous_updatebool

Whether to allow drag and drop or only to click on the plot.

draw_custom_picker

A function that takes the axis object and a tuple (selected_x, selected_y) of the selected point on the plot. Allows the user to draw a different picker, instead of the default plot.

Attributes#

xlabelstr

The label of the x-axis. Defaults to None.

ylabelstr

The label of the y-axis. Defaults to None.

callback_object

A callback object which is given to the sel_callback function if set. See also sel_callback in the __init__() function. Defaults to None.

Furthermore, all of the parameters which the __init__() function takes are also attributes.

Methods

show()

Connects all of the listeners and redraws the plot

update()

Redraws the plot