From 2a13f375d49d9175e16b1f0cd953d347bcca43dc Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 29 Nov 2015 18:26:05 +0100 Subject: Finish assignment 4 --- Assignment 4/packages/clusterPlot.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'Assignment 4/packages') 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() -- cgit v1.2.3