function plot_iris(data, feat1, feat2, centroids, clust_class)

% function plot_iris(data, feat1, feat2, centroids)
% 
% Plot two features of Iris dataset to make it possible to visualize,
% together with locations of centroids found by k-means algorithm.
% 
% Inputs :  data            - Iris data to be plotted.
%           feat1           - Feature on x-axis.
%           feat2           - Feature on y-axis.
%           centroids       - Centroids' locations.
%           clust_class     - Classes that centroids will predict.
% Outputs:  none.
%
% Author: Nemanja Djuric
% Date  : Sept. 25th, 2010

% separate data to make it easier to work with
label = data(:, 5);
features = data(:, 1 : 4);

% find classes in data
class1 = find(label == 1);
class2 = find(label == 2);
class3 = find(label == 3);

% plot the data
figure(1), clf;
plot(features(class1, feat1), features(class1, feat2), 'r*', ...
     features(class2, feat1), features(class2, feat2), 'g*', ...
     features(class3, feat1), features(class3, feat2), 'b*');

% plot the centroids found by k-means algorithm
feature_names = {'sepal length [cm]', 'sepal width [cm]', 'petal length [cm]', 'petal width [cm]'};
class_colors = ['r', 'g', 'b'];
if (~isempty(centroids))
    hold on;
    for i = 1 : length(clust_class)
        plot(centroids(i, feat1), centroids(i, feat2), 'kp', 'MarkerSize', 25, 'MarkerFaceColor', class_colors(clust_class(i)));
    end;
    xlabel(feature_names{feat1});
    ylabel(feature_names{feat2});
    hold off;
end;