Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

tab20b.m 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. function map = tab20b(N)
  2. % Qualitative colormap from MatPlotLib, for plots using the line ColorOrder.
  3. % In MatPlotLib 2 it is named VEGA20b, for MatPlotLib 3 was renamed TAB20b.
  4. %
  5. % Copyright (c) 2017-2019 Stephen Cobeldick
  6. %
  7. %%% Syntax:
  8. % map = tab20b
  9. % map = tab20b(N)
  10. %
  11. % For MatPlotLib 2.0 improved colormaps were created for plot lines of
  12. % categorical data. The new colormaps are introduced here:
  13. % <http://matplotlib.org/2.0.0rc2/users/dflt_style_changes.html>
  14. % VEGA10/TAB10 is the default Line Color Order for MatPlotLib 2 and 3.
  15. %
  16. % MATLAB axes ColorOrder (note that this is NOT the axes COLORMAP):
  17. % <https://www.mathworks.com/help/matlab/creating_plots/defining-the-color-of-lines-for-plotting.html>
  18. % <https://www.mathworks.com/help/matlab/graphics_transition/why-are-plot-lines-different-colors.html>
  19. %
  20. %% Examples %%
  21. %
  22. %%% PLOT using matrices:
  23. % N = 20;
  24. % axes('ColorOrder',tab20b(N),'NextPlot','replacechildren')
  25. % X = linspace(0,pi*3,1000);
  26. % Y = bsxfun(@(x,n)sqrt(n)*sin(x+2*n*pi/N), X(:), 1:N);
  27. % plot(X,Y, 'linewidth',4)
  28. %
  29. %%% PLOT in a loop:
  30. % N = 20;
  31. % set(0,'DefaultAxesColorOrder',tab20b(N))
  32. % X = linspace(0,pi*3,1000);
  33. % Y = bsxfun(@(x,n)sqrt(n)*sin(x+2*n*pi/N), X(:), 1:N);
  34. % for n = 1:N
  35. % plot(X(:),Y(:,n), 'linewidth',4);
  36. % hold all
  37. % end
  38. %
  39. %%% LINE using matrices:
  40. % N = 20;
  41. % set(0,'DefaultAxesColorOrder',tab20b(N))
  42. % X = linspace(0,pi*3,1000);
  43. % Y = bsxfun(@(x,n)sqrt(n)*cos(x+2*n*pi/N), X(:), 1:N);
  44. % line(X(:),Y)
  45. %
  46. %% Input and Output Arguments %%
  47. %
  48. %%% Inputs (*=default):
  49. % N = NumericScalar, N>=0, an integer to define the colormap length.
  50. % = *[], use the length of the current figure's colormap (see COLORMAP).
  51. %
  52. %%% Outputs:
  53. % map = NumericMatrix, size Nx3, a colormap of RGB values between 0 and 1.
  54. %
  55. % See also TAB10 TAB20 TAB20C SET TWILIGHT VIRIDIS LINES COLORMAP PARULA
  56. if nargin<1
  57. N = size(get(gcf,'colormap'),1);
  58. else
  59. assert(isscalar(N)&&isreal(N),'First argument must be a real numeric scalar.')
  60. assert(fix(N)==N&&N>=0,'First argument must be a positive integer.')
  61. end
  62. %
  63. hex = ['#393b79';'#5254a3';'#6b6ecf';'#9c9ede';'#637939';'#8ca252';'#b5cf6b';'#cedb9c';'#8c6d31';'#bd9e39';'#e7ba52';'#e7cb94';'#843c39';'#ad494a';'#d6616b';'#e7969c';'#7b4173';'#a55194';'#ce6dbd';'#de9ed6'];
  64. raw = sscanf(hex.','#%2x%2x%2x',[3,Inf]).';
  65. %
  66. map = raw(1+mod(0:N-1,size(raw,1)),:) / 255;
  67. %
  68. end
  69. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%tab20b