PlotValueMatrix.m 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. % PlotValueMatrix.m
  2. %
  3. % This function plots the provided value matrix. The columns are plotted
  4. % in the X axis and the rows in the Y axis.
  5. function PlotValueMatrix(matrix)
  6. numValues = sum(matrix,1); % columnwise summation
  7. sumMatrix = matrix;
  8. for i=1:size(matrix,1)
  9. sumMatrix(i,:) = matrix(i,:) * i;
  10. end
  11. sumValues = sum(sumMatrix, 1);
  12. meanValues = sumValues./numValues;
  13. percMatrix = matrix;
  14. for i=1:size(matrix,2)
  15. percMatrix(:,i) = matrix(:,i)./numValues(i);
  16. end
  17. figure;
  18. hold on;
  19. if (size(matrix,1) > 2)
  20. maxTarSize = 120;
  21. else
  22. maxTarSize = 50;
  23. end
  24. colors = {'r'; 'g'; 'y'; 'k'; 'm'};
  25. for i=1:size(percMatrix,1)
  26. for j=1:size(percMatrix,2)
  27. markerSize = percMatrix(i,j)*maxTarSize;
  28. if (markerSize < 1)
  29. continue;
  30. end
  31. plot(j, i, '.', 'color', colors{j,1}, 'markerSize', markerSize);
  32. end
  33. end
  34. meanTarSize = 30;
  35. p = plot(meanValues, '.-b', 'markersize', meanTarSize);
  36. h = plot(-1, -1, '.r', 'markerSize', meanTarSize);
  37. legend([h p], {'Μέγεθος δείγματος ανα στήλη στον άξονα Χ', 'Μέση τιμή'}, 'location', 'northeast');
  38. box on;
  39. end