CustomViewer¶
- class glue.viewers.custom.qt.custom_viewer.CustomViewer(viewer)[source]¶
Bases:
object
Base 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).axes
will contain a matplotlib Axes objectroi
will contain the ROI a user has drawn (only available formake_selector
)state
will contain a general-purpose object to store other datastyle
contains theVisualAttributes
describing a subset or dataset. Only available forplot_data
and plot_subset`subset
will contain the relevantSubset
object.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
Methods Summary
create_new_subclass
(name, **kwargs)Convenience method to build a new CustomViewer subclass.
Custom method called to build a
SubsetState
from an ROI.Custom method called to show a dataset
Custom method called to show a subset
select
()Custom method called to filter data using an ROI.
Custom method called when UI settings change.
setup
()Custom method called when plot is created
Attributes Documentation
- name = ''¶
- ui = {}¶
Methods Documentation
- classmethod create_new_subclass(name, **kwargs)[source]¶
Convenience method to build a new CustomViewer subclass.
This is used by the custom_viewer function.
- Parameters:
- namestr
Name of the new viewer
- kwargs
UI elements in the subclass
- make_selector()¶
Custom method called to build a
SubsetState
from 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
roi
argument to this function
- plot_data()¶
Custom method called to show a dataset
- plot_subset()¶
Custom method called to show a subset
- 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
roi
argument to this function
- settings_changed()¶
Custom method called when UI settings change.
- setup()¶
Custom method called when plot is created