plot_comunity.m 602 B

123456789101112131415161718192021222324
  1. function plot_comunity(M)
  2. %n_comunity = length(unique(M));
  3. [~,idx_com] = unique(sort(M),'last');
  4. n_units_per_comunity = diff([0;idx_com]);
  5. idx = find(n_units_per_comunity>1);
  6. tmp = linspace(0.5,0.8,length(idx));
  7. colors = repmat(tmp,3,1);
  8. for i=1:length(idx)
  9. comunity_idx = find(M == idx(i));
  10. start = comunity_idx(1);
  11. finish = comunity_idx(end);
  12. x1 = start - 0.5;x2 = finish + 0.5;
  13. y1 = start - 0.5;y2 = finish + 0.5;
  14. x = [x1, x2, x2, x1, x1];
  15. y = [y1, y1, y2, y2, y1];
  16. hold all
  17. plot(x, y, '-','Color',colors(:,i),'LineWidth',2);
  18. end
  19. end