CustomViewer¶
-
class
glue.viewers.custom.qt.custom_viewer.CustomViewer(viewer)[source]¶ Bases:
objectBase class for custom data viewers.
Users can either subclass this class and override one or more custom methods listed below, or use the
glue.custom_viewer()function and decorate custom plot functions.Custom Plot Methods
The following methods can be overridden:
Method Signatures
Custom methods should use argument names from the following list:
The name of a UI element (e.g. keywords passed to
glue.custom_viewer(), or class-level variables in subclasses). The value assigned to this argument will be the current UI setting (e.g. booleans for checkboxes).axeswill contain a matplotlib Axes objectroiwill contain the ROI a user has drawn (only available formake_selector)statewill contain a general-purpose object to store other datastylecontains theVisualAttributesdescribing a subset or dataset. Only available forplot_dataand plot_subset`subsetwill contain the relevantSubsetobject.Only available for
plot_subset
Defining the UI
Simple widget-based UIs can be specified by providing keywords to
custom_viewer()or class-level variables to subsets. The kind of widget to associate with each UI element is determined from it’s type.Example decorator
v = custom_viewer('Example', checkbox=False) @v.plot_data def plot(checkbox, axes): axes.plot([1, 2, 3])
Example subclass
class CustomViewerSubset(CustomViewer): checkbox = False def plot_data(self, checkbox, axes): axes.plot([1, 2, 3])
The order of arguments can be listed in any order.
Attributes Summary
make_selector(func)Custom method called to build a
SubsetStatefrom an ROI.plot_data(func)Custom method called to show a dataset
plot_subset(func)Custom method called to show a subset
select(func)Custom method called to filter data using an ROI.
settings_changed(func)Custom method called when UI settings change.
setup(func)Custom method called when plot is created
Methods Summary
create_new_subclass(name, \*\*kwargs)Convenience method to build a new CustomViewer subclass.
Attributes Documentation
-
make_selector(func) = functools.partial(<bound method CustomViewer._register_override_method of <class 'glue.viewers.custom.qt.custom_viewer.CustomViewer'>>, 'make_selector')¶ Custom method called to build a
SubsetStatefrom an ROI.See
select()for an alternative way to define selections, by returning Boolean arrays instead of SubsetStates.Functions have access to the roi by accepting an
roiargument to this function
-
name= ''¶
-
plot_data(func) = functools.partial(<bound method CustomViewer._register_override_method of <class 'glue.viewers.custom.qt.custom_viewer.CustomViewer'>>, 'plot_data')¶ Custom method called to show a dataset
-
plot_subset(func) = functools.partial(<bound method CustomViewer._register_override_method of <class 'glue.viewers.custom.qt.custom_viewer.CustomViewer'>>, 'plot_subset')¶ Custom method called to show a subset
-
select(func) = functools.partial(<bound method CustomViewer._register_override_method of <class 'glue.viewers.custom.qt.custom_viewer.CustomViewer'>>, 'select')¶ Custom method called to filter data using an ROI.
This is an alternative function to
make_selector(), which returns a numpy boolean array instead of a SubsetState.Functions have access to the roi by accepting an
roiargument to this function
-
settings_changed(func) = functools.partial(<bound method CustomViewer._register_override_method of <class 'glue.viewers.custom.qt.custom_viewer.CustomViewer'>>, 'settings_changed')¶ Custom method called when UI settings change.
-
setup(func) = functools.partial(<bound method CustomViewer._register_override_method of <class 'glue.viewers.custom.qt.custom_viewer.CustomViewer'>>, 'setup')¶ Custom method called when plot is created
-
ui= {}¶
Methods Documentation