Add subset_points argument to points plotting method
@@ -422,6 +422,7 @@ def points(
width=800,
height=800,
show_legend=True,
+ subset_points=None,
):
"""Plot an embedding as points. Currently this only works
for 2D embeddings. While there are many optional parameters
@@ -517,6 +518,10 @@ def points(
show_legend: bool (optional, default True)
Whether to display a legend of the labels
+ subset_points: array, shape (n_samples,) (optional, default None)
+ A way to select a subset of points based on an array of boolean
+ values.
+
Returns
-------
result: matplotlib axis
@@ -541,6 +546,14 @@ def points(
points = umap_object.embedding_
+ if subset_points is not None:
+ points = points[subset_points]
+
+ if labels is not None:
+ labels = labels[subset_points]
+ if values is not None:
+ values = values[subset_points]
+
if points.shape[1] != 2:
raise ValueError("Plotting is currently only implemented for 2D embeddings")
@@ -1280,8 +1293,8 @@ def interactive(
if subset_points is not None:
if len(subset_points) != points.shape[0]:
raise ValueError(
- "Size of subset points ({}) does not match number of input points ({})" \
- .format(len(subset_points), points.shape[0]
+ "Size of subset points ({}) does not match number of input points ({})".format(
+ len(subset_points), points.shape[0]
)
)
