CustomViewer¶
-
class
glue.viewers.custom.qt.custom_viewer.CustomViewer(widget_instance)[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. bools 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_selectorCustom method called to build a SubsetStatefrom an ROI.nameLabel to give this widget in the GUI plot_dataCustom method called to show a dataset plot_subsetCustom method called to show a subset redraw_on_settings_changeredraw all layers when UI state changes? remove_artistsauto-delete artists? selectCustom method called to filter data using an ROI. selections_enabledsettings_changedCustom method called when UI settings change. setupCustom method called when plot is created uiMethods Summary
create_axes(figure)Build a new axes object create_new_subclass(name, **kwargs)Convenience method to build a new CustomViewer subclass register_to_hub(hub)settings()Return a frozen copy of the current settings of the viewer unregister(hub)value(key[, layer, view])Attributes Documentation
-
make_selector= <functools.partial object>¶ 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= ''¶ Label to give this widget in the GUI
-
plot_data= <functools.partial object>¶ Custom method called to show a dataset
-
plot_subset= <functools.partial object>¶ Custom method called to show a subset
-
redraw_on_settings_change= True¶ redraw all layers when UI state changes?
-
remove_artists= True¶ auto-delete artists?
-
select= <functools.partial object>¶ 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
-
selections_enabled¶
-
settings_changed= <functools.partial object>¶ Custom method called when UI settings change.
-
setup= <functools.partial object>¶ Custom method called when plot is created
-
ui= {}¶
Methods Documentation