From 8c8d06c8aec83c44b86e08c95b641c8d80213660 Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Tue, 20 May 2014 14:44:59 +0100 Subject: [PATCH] [pca] colors now as iterator --- GPy/util/pca.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/GPy/util/pca.py b/GPy/util/pca.py index 6c548b3d..967d0e1b 100644 --- a/GPy/util/pca.py +++ b/GPy/util/pca.py @@ -106,12 +106,14 @@ class pca(object): ulabels.append(lab) nlabels = len(ulabels) if colors is None: - colors = [cmap(float(i) / nlabels) for i in range(nlabels)] + colors = iter([cmap(float(i) / nlabels) for i in range(nlabels)]) + else: + colors = iter(colors) X_ = self.project(X, self.Q)[:,dimensions] kwargs.update(dict(s=s)) plots = list() for i, l in enumerate(ulabels): - kwargs.update(dict(color=colors[i], marker=marker[i % len(marker)])) + kwargs.update(dict(color=colors.next(), marker=marker[i % len(marker)])) plots.append(ax.scatter(*X_[labels == l, :].T, label=str(l), **kwargs)) ax.set_xlabel(r"PC$_1$") ax.set_ylabel(r"PC$_2$")