Skip to content

Commit 5e72097

Browse files
committed
Get selections for scatter and force
1 parent e716a18 commit 5e72097

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

Diff for: lightning/types/images.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,24 @@ def clean(imagedata, coordinates=None, xy=None):
6262

6363
return outdict
6464

65-
@property
6665
def _coords(self):
6766
"""
68-
Coordinates of regions retrieved from visualization user data.
67+
Raw coordinates of regions retrieved from visualization user data.
6968
"""
7069
user_data = self.get_user_data()['settings']
7170
if 'coords' in user_data.keys():
7271
return [c for c in user_data['coords'] if len(c) > 1]
7372
else:
7473
return []
7574

76-
@property
7775
def polygons(self):
7876
"""
7977
Coordinates of polygons as drawn on an image.
8078
8179
These coordinates can be drawn directly to an image using lighting.imagepoly
82-
and should be in the exact same locatinos as they were drawn.
80+
and should be in the exact same locations as they were drawn.
8381
"""
84-
coords = self._coords
82+
coords = self._coords()
8583
# convert from x/y to row/column indexing
8684
polygons = map(lambda b: asarray(b)[:, ::-1].tolist(), coords)
8785
return polygons
@@ -92,10 +90,10 @@ def points(self, z=None):
9290
9391
Parameters
9492
----------
95-
z : int, optiona, default=None
93+
z : int, optional, default=None
9694
Append a z-index to coordinates (yielding three dimensional coordinates)
9795
"""
98-
coords = self._coords
96+
coords = self._coords()
9997
return [polygon_to_points(x, z) for x in coords]
10098

10199
def masks(self, dims, z=None):
@@ -111,7 +109,7 @@ def masks(self, dims, z=None):
111109
Use a z-index to insert regions into the appropriate slice if using
112110
three-dimensional volumes.
113111
"""
114-
coords = self._coords
112+
coords = self._coords()
115113
return [polygon_to_mask(x, dims, z) for x in coords]
116114

117115

Diff for: lightning/types/linked.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ScatterLine(Base):
99
_func = 'scatterline'
1010

1111
@staticmethod
12-
def clean(x, y, series, color=None, label=None, size=None, alpha=None):
12+
def clean(x, y, series, color=None, label=None, value=None, colormap=None, size=None, alpha=None):
1313
"""
1414
Create a joint scatter / line plot.
1515
@@ -29,6 +29,12 @@ def clean(x, y, series, color=None, label=None, size=None, alpha=None):
2929
label : array-like, optional, singleton or (n,)
3030
Single integer or array to set point colors via group labels
3131
32+
value : array-like, optional, singleton or (n,)
33+
Values to set node colors via a linear scale
34+
35+
colormap : string
36+
Specification of color map, only colorbrewer types supported
37+
3238
size : array-like, optional, singleton or (n,)
3339
Single size or array to set point sizes
3440
"""
@@ -39,6 +45,8 @@ def clean(x, y, series, color=None, label=None, size=None, alpha=None):
3945

4046
outdict = add_property(outdict, color, 'color')
4147
outdict = add_property(outdict, label, 'label')
48+
outdict = add_property(outdict, value, 'value')
49+
outdict = add_property(outdict, colormap, 'colormap')
4250
outdict = add_property(outdict, size, 'size')
4351
outdict = add_property(outdict, alpha, 'alpha')
4452

Diff for: lightning/types/plots.py

+21
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ def clean(x, y, color=None, label=None, value=None, colormap=None, size=None, al
6969

7070
return outdict
7171

72+
def selected(self):
73+
"""
74+
Selected points from scatter plot
75+
"""
76+
user_data = self.get_user_data()['settings']
77+
if 'selected' in user_data.keys():
78+
return user_data['selected']
79+
else:
80+
return []
81+
82+
7283
@viztype
7384
class Matrix(Base):
7485

@@ -280,6 +291,16 @@ def clean(conn, color=None, label=None, value=None, colormap=None, size=None):
280291

281292
return outdict
282293

294+
def selected(self):
295+
"""
296+
Selected points from force plot
297+
"""
298+
user_data = self.get_user_data()['settings']
299+
if 'selected' in user_data.keys():
300+
return user_data['selected']
301+
else:
302+
return []
303+
283304
@viztype
284305
class Graph(Base):
285306

0 commit comments

Comments
 (0)