brewermap_plot.m 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. function brewermap_plot()
  2. % Simple plot of all ColorBrewer colorscheme nodes in one figure.
  3. %
  4. % (c) 2014-2020 Stephen Cobeldick
  5. %
  6. %%% Syntax:
  7. % brewermap_plot()
  8. %
  9. % See also BREWERMAP CUBEHELIX LBMAP PARULA LINES RGBPLOT COLORMAP COLORBAR PLOT PLOT3 AXES SET
  10. [scm,num,typ] = brewermap('list');
  11. %
  12. persistent cbh axh
  13. %
  14. xmx = max(num);
  15. ymx = numel(typ);
  16. %
  17. if ishghandle(cbh)
  18. figure(cbh);
  19. delete(axh);
  20. else
  21. cbh = figure('HandleVisibility','callback', 'IntegerHandle','off',...
  22. 'NumberTitle','off', 'Name',mfilename,'Color','white',...
  23. 'MenuBar','figure', 'Toolbar','none', 'Tag',mfilename);
  24. set(cbh,'Units','pixels')
  25. pos = get(cbh,'Position');
  26. pos(1:2) = pos(1:2) - 123;
  27. pos(3:4) = max(pos(3:4),[842,532]);
  28. set(cbh,'Position',pos)
  29. end
  30. %
  31. axh = axes('Parent',cbh, 'Color','none',...
  32. 'XTick',0:xmx, 'YTick',0.5:ymx, 'YTickLabel',scm, 'YDir','reverse');
  33. title(axh,'ColorBrewer Color Schemes (brewermap.m)', 'Interpreter','none')
  34. xlabel(axh,'Scheme Nodes')
  35. ylabel(axh,'Scheme Name')
  36. axf = get(axh,'FontName');
  37. %
  38. for y = 1:ymx
  39. N = num(y);
  40. M = brewermap(N,scm{y});
  41. for x = 1:N
  42. patch([x-1,x-1,x,x],[y-1,y,y,y-1],1, 'FaceColor',M(x,:), 'Parent',axh)
  43. end
  44. text(xmx+0.1,y-0.5,typ{y}, 'Parent',axh, 'FontName',axf)
  45. end
  46. %
  47. drawnow()
  48. %
  49. end
  50. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%brewermap_plot