aboutsummaryrefslogtreecommitdiff
path: root/Assignment 4/packages
diff options
context:
space:
mode:
authorCamil Staps2015-11-29 18:26:05 +0100
committerCamil Staps2015-11-29 18:26:05 +0100
commit2a13f375d49d9175e16b1f0cd953d347bcca43dc (patch)
tree841ba6ba827f63ce2ad79cfdaff7c0c30e477959 /Assignment 4/packages
parentFinish assignment 4 (diff)
Finish assignment 4
Diffstat (limited to 'Assignment 4/packages')
-rw-r--r--Assignment 4/packages/clusterPlot.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/Assignment 4/packages/clusterPlot.py b/Assignment 4/packages/clusterPlot.py
index 2f37a3d..4abc2c0 100644
--- a/Assignment 4/packages/clusterPlot.py
+++ b/Assignment 4/packages/clusterPlot.py
@@ -4,7 +4,7 @@ Created on Mon Apr 14 09:01:18 2014
"""
-def clusterPlot(X, clusterid, centroids='None', y='None', covars='None', figsize=(16,10)):
+def clusterPlot(X, clusterid, centroids='None', y='None', covars='None', figsize=None):
'''
CLUSTERPLOT Plots a clustering of a data set as well as the true class
labels. If data is more than 2-dimensional it should be first projected
@@ -27,7 +27,7 @@ def clusterPlot(X, clusterid, centroids='None', y='None', covars='None', figsize
covars M-by-M-by-K tensor of covariance matrices (optional)
'''
import numpy as np
- from matplotlib.pyplot import figure, cm, plot, hold, legend, xlim, show
+ from matplotlib.pyplot import figure, cm, plot, hold, legend, xlim
X = np.asarray(X)
@@ -43,7 +43,8 @@ def clusterPlot(X, clusterid, centroids='None', y='None', covars='None', figsize
ncolors = np.max([C,K])
# plot data points color-coded by class, cluster markers and centroids
- figure(figsize=figsize)
+ if figsize != None:
+ figure(figsize=figsize)
hold(True)
colors = [0]*ncolors
for color in range(ncolors):
@@ -71,5 +72,3 @@ def clusterPlot(X, clusterid, centroids='None', y='None', covars='None', figsize
legend(legend_items, numpoints=1, markerscale=.75, prop={'size': 9})
xlim(X[:,0].min()*1.1, X[:,0].max()*1.2)
-
- show()