forked from cortex-lab/phy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
color_scheme.py
23 lines (19 loc) · 979 Bytes
/
color_scheme.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Show how to add a custom color scheme to a view."""
from phy import IPlugin, connect
from phy.cluster.views import ClusterScatterView
class ExampleColorSchemePlugin(IPlugin):
def attach_to_controller(self, controller):
# Initial actions when creating views.
@connect
def on_view_attached(view, gui):
# We need the initial list of cluster ids to initialize the color map.
cluster_ids = controller.supervisor.clustering.cluster_ids
if isinstance(view, ClusterScatterView):
# Each view has a set of color schemes among which one can cycle through in
# the GUI.
view.add_color_scheme(
name='mycolorscheme',
fun=controller.get_cluster_amplitude, # cluster_id => value
colormap='rainbow', # or use a colorcet color map or a custom N*3 array
cluster_ids=cluster_ids,
)