function [S,m,l,t,s]=som_grid(varargin)
%SOM_GRID Visualization of a SOM grid
%
% [sGrid,m,l,t,s]=som_grid(sGrid, ['argID', value, ...])
% [sGrid,m,l,t,s]=som_grid(topol, ['argID', value, ...])
% [sGrid,m,l,t,s]=som_grid(lattice, msize, ['argID', value, ...])
%
% Input and output arguments ([]'s are optional)
% sGrid (struct) som_grid struct (see output arguments)
% topol (struct) map or topol struct for giving the topology
% (cell array) of form {'lattice', msize, ['shape']}.
% Default value for 'shape' is 'sheet'.
% lattice (string) 'hexa', 'rect'
% (matrix) size M x M, defines topological connections
% msize (vector) 1x2 vector defines the grid size, M=msize(1)*msize(2)
% ['argID',(string) Other arguments can be given as 'argID', value
% value] (varies) pairs. See list below for valid values.
%
% sGrid (struct) with fields S.msize, S.shape, S.lattice, S.coord, S.marker,
% S.markersize, S.markercolor, S.line, S.linewidth, S.linecolor,
% S.surf, S.label, S.labelsize, S.labelcolor
% m (matrix) handels to LINE objects (unit markers)
% l (matrix) handles to LINE objects (lines connecting the units)
% t (matrix) handles to TEXT objects (labels)
% s (scalar) handle to SURF object (surface between units)
%
% Here are the valid argument IDs (case insensitive) and
% associated values:
% 'Coord' Mx2 or Mx3 matrix of coordinates
% (default: according to lattice as in som_cplane)
% 'Marker' string 'o','+','x','*','v','^','<','>','h','s','d','p','.',
% 'none' or Mx1 cell or char array of these strings
% Default: 'o'.
% 'MarkerSize' scalar or Mx1 matrix of double. Default: 6.
% 'MarkerColor' ColorSpec or Mx3 matrix of RGB triples. Default: 'k'.
% 'Line' string '-',':','--' or '-.' or 'none'. Default: '-'.
% 'Surf' [], Mx1 or Mx3 matrix of RGB triples
% to define surface values. Default: [] = no surf.
% Note: shading is turned to 'interp'.
% 'LineWidth' scalar or MxM matrix, default: 0.5
% 'LineColor' ColorSepc, MxMx3 matrix of RGB triples or a cell array
% of form {r g b} where r,g, and b are MxM
% (sparse) matrices of R,G, and B values
% 'Label' Mx1 char array, cell array of strings size MxL
% or [] to indicate no labels, default: [] = no labels.
% 'LabelSize' scalar
% 'LabelColor' ColorSpec or string 'none', default: 'g'.
%
% For more help, try 'type som_grid' or check out online documentation.
% See also SOM_CONNECTION, SOM_SHOW, SOM_CPLANE, SOM_SET, SCATTER, SCATTER3.