Package topo :: Package plotting :: Module plotgroup :: Class TemplatePlotGroup
[hide private]
[frames] | no frames]

Class TemplatePlotGroup

source code


Container that allows creation of different types of plots in a way that is independent of particular models or Sheets.

A TemplatePlotGroup is constructed from a plot_templates list, an optional command to run to generate the data, and other optional parameters.

The plot_templates list should contain tuples (plot_name, plot_template). Each plot_template is a list of (name, value) pairs, where each name specifies a plotting channel (such as Hue or Confidence), and the value is the name of a SheetView (such as Activity or OrientationPreference).

Various types of plots support different channels. An SHC plot supports Strength, Hue, and Confidence channels (with Strength usually being visualized as luminance, Hue as a color value, and Confidence as the saturation of the color). An RGB plot supports Red, Green, and Blue channels. Other plot types will be added eventually.

For instance, one could define an Orientation-colored Activity plot as:

plotgroups['Activity'] =
    TemplatePlotGroup(name='Activity', category='Basic',
        pre_plot_hooks=[measure_activity],
        plot_templates=[('Activity',
            {'Strength': 'Activity', 'Hue': 'OrientationPreference', 'Confidence': None})])

This specifies that the final TemplatePlotGroup will contain up to one Plot named Activity per Sheet, although there could be no plots at all if no Sheet has a SheetView named Activity once 'measure_activity()' has been run. The Plot will be colored by OrientationPreference if such a SheetView exists for that Sheet, and the value (luminance) channel will be determined by the SheetView Activity. This plot will be listed in the category 'Basic' anywhere such categories are relevant (e.g. in the GUI).

Here's a more complicated example specifying two different plots in the same PlotGroup:

TemplatePlotGroup(name='Orientation Preference', category='Basic'
    pre_plot_hooks=[measure_or_pref.instance()],
    plot_templates=
        [('Orientation Preference',
            {'Strength': None, 'Hue': 'OrientationPreference'}),
         ('Orientation Selectivity',
            {'Strength': 'OrientationSelectivity'})])

Here the TemplatePlotGroup will contain up to two Plots per Sheet, depending on which Sheets have OrientationPreference and OrientationSelectivity SheetViews.

The function create_plotgroup provides a convenient way to define plots using TemplatePlotGroups; search for create_plotgroup elsewhere in the code to see examples.

Nested Classes [hide private]

Inherited from param.parameterized.Parameterized: __metaclass__

Instance Methods [hide private]
 
_generate_plots(self)
Return the list of Plots
source code
 
__init__(self, plot_templates=None, static_images=None, **params)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
add_template(self, name, specification_tuple_list) source code
 
add_plot(self, name, specification_tuple_list) source code
 
add_static_image(self, name, file_path)
Construct a static image Plot (e.g.
source code
 
_template_plots(self, range_=False) source code
 
_kw_for_make_template_plot(self, range_) source code
 
_make_template_plot(self, plot_template_name, plot_template, **kw) source code

Inherited from SheetPlotGroup: scale_images, sheets, update_maximum_plot_height

Inherited from PlotGroup: make_plots

Inherited from param.parameterized.Parameterized: __getstate__, __repr__, __setstate__, __str__, debug, defaults, force_new_dynamic_value, get_param_values, get_value_generator, inspect_value, message, print_param_values, script_repr, set_default, set_dynamic_time_fn, set_param, state_pop, state_push, verbose, warning

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]

Inherited from param.parameterized.Parameterized: params, print_param_defaults

Class Variables [hide private]
  doc = param.String(default= "", doc= ...
Documentation string describing this type of plot.
  plot_immediately = param.Boolean(False, doc= ...
Whether to call the pre-plot hooks at once or only when the user asks for a refresh.
  prerequisites = param.List([], doc= ...
List of preference maps that must exist before this plot can be calculated.
  category = param.String(default= "User", doc= ...
Category to which this plot belongs, which will be created if necessary.
  normalize = param.ObjectSelector(default= 'None', objects= ['N...
'Individually': scale each plot so that its maximum value is white and its minimum value black.
  name = <param.parameterized.String object at 0xaafa4ec>
String identifier for this object.

Inherited from SheetPlotGroup: auto_refresh, desired_maximum_plot_height, enforce_minimum_plot_height, integer_scaling, sheet_coords

Inherited from PlotGroup: plot_hooks, pre_plot_hooks

Inherited from param.parameterized.Parameterized: print_level

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_generate_plots(self)

source code 
Return the list of Plots
Overrides: PlotGroup._generate_plots
(inherited documentation)

__init__(self, plot_templates=None, static_images=None, **params)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

add_static_image(self, name, file_path)

source code 
Construct a static image Plot (e.g. a color key for an Orientation Preference map).

Class Variable Details [hide private]

doc

Documentation string describing this type of plot.
Value:
param.String(default= "", doc= """
        Documentation string describing this type of plot.""")

plot_immediately

Whether to call the pre-plot hooks at once or only when the user asks for a refresh.

Should be set to true for quick plots, but false for those that take a long time to calculate, so that the user can change the hooks if necessary.

Value:
param.Boolean(False, doc= """
        Whether to call the pre-plot hooks at once or only when the user asks for \
a refresh.
 
        Should be set to true for quick plots, but false for those that take a lon\
g time
        to calculate, so that the user can change the hooks if necessary.""")

prerequisites

List of preference maps that must exist before this plot can be calculated.
Value:
param.List([], doc= """
        List of preference maps that must exist before this plot can be calculated\
.""")

category

Category to which this plot belongs, which will be created if necessary.
Value:
param.String(default= "User", doc= """
        Category to which this plot belongs, which will be created if necessary.""\
")

normalize

'Individually': scale each plot so that its maximum value is white and its minimum value black.

'None': no scaling (0.0 will be black and 1.0 will be white).

'AllTogether': scale each plot so that the highest maximum value is white, and the lowest minimum value is black.

Normalizing 'Individually' has the advantage of ensuring that any data that is present will be visible, but the disadvantage that the absolute scale will be obscured. Non-normalized plots are guaranteed to be on a known scale, but only values between 0.0 and 1.0 will be visibly distinguishable.

Value:
param.ObjectSelector(default= 'None', objects= ['None', 'Individually', 'AllTogeth\
er'], doc= """
        
        'Individually': scale each plot so that its maximum value is
        white and its minimum value black.

        'None': no scaling (0.0 will be black and 1.0 will be white).

...