CustomViewer#

class glue_qt.viewers.custom.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 object

  • roi will contain the ROI a user has drawn (only available for make_selector)

  • state will contain a general-purpose object to store other data

  • style contains the VisualAttributes describing a subset or dataset. Only available for plot_data and plot_subset`

  • subset will contain the relevant Subset 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.

make_selector()

Register a new custom method like "plot_data"

plot_data()

Register a new custom method like "plot_data"

plot_subset()

Register a new custom method like "plot_data"

select()

Register a new custom method like "plot_data"

settings_changed()

Register a new custom method like "plot_data"

setup()

Register a new custom method like "plot_data"

Attributes Documentation

name = ''#
selections_enabled[source]#
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()#

Register a new custom method like “plot_data”

Users need not call this directly - it is called when a method is overridden or decorated

plot_data()#

Register a new custom method like “plot_data”

Users need not call this directly - it is called when a method is overridden or decorated

plot_subset()#

Register a new custom method like “plot_data”

Users need not call this directly - it is called when a method is overridden or decorated

select()#

Register a new custom method like “plot_data”

Users need not call this directly - it is called when a method is overridden or decorated

settings_changed()#

Register a new custom method like “plot_data”

Users need not call this directly - it is called when a method is overridden or decorated

setup()#

Register a new custom method like “plot_data”

Users need not call this directly - it is called when a method is overridden or decorated