annotate core/magnatagatune/tag_stats.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function out = tag_stats(annots, names, max_plot)
wolffd@0 2 % out = tag_stats(annots, names, max_plot)
wolffd@0 3 %
wolffd@0 4 % calculates statistics for tag distributions
wolffd@0 5 % and plots them
wolffd@0 6
wolffd@0 7 if nargin < 3
wolffd@0 8 max_plot = 25;
wolffd@0 9 end
wolffd@0 10
wolffd@0 11 % get overall frequency and sort accordingly
wolffd@0 12 allapp = sum(annots > 0, 1);
wolffd@0 13 % allapp = allapp/max(allapp);
wolffd@0 14
wolffd@0 15 [null, idx] = sort(allapp,'descend');
wolffd@0 16
wolffd@0 17 % ---
wolffd@0 18 % visualize only the fist top 200
wolffd@0 19 % ---
wolffd@0 20 max_plot = min(numel(names), max_plot);
wolffd@0 21
wolffd@0 22 figure;
wolffd@0 23 bar(1:max_plot,allapp(idx(1:max_plot)))
wolffd@0 24 set(gca,'XTick',1:max_plot);
wolffd@0 25 set(gca,'XTickLabel',names(idx(1:max_plot)));
wolffd@0 26 axis([1 max_plot 0 max(allapp)])
wolffd@0 27
wolffd@0 28 legend('#appearances');
wolffd@0 29 title 'tag statistics sorted by frequency of appearances'
wolffd@0 30
wolffd@0 31 out = [];