annotate toolboxes/MIRtoolbox1.3.2/somtoolbox/som_show_add.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 h=som_show_add(mode,D,varargin)
wolffd@0 2
wolffd@0 3 %SOM_SHOW_ADD Shows hits, labels and trajectories on SOM_SHOW visualization
wolffd@0 4 %
wolffd@0 5 % h = som_show_add(mode, D, ['argID',value,...])
wolffd@0 6 %
wolffd@0 7 % som_show_add('label',sMap)
wolffd@0 8 % som_show_add('hit',som_hits(sMap,sD))
wolffd@0 9 % som_show_add('traj',som_bmus(sMap,sD))
wolffd@0 10 % som_show_add('comet',som_bmus(sMap,sD))
wolffd@0 11 % som_show_add('comet',inds, 'markersize', [1 0.2])
wolffd@0 12 %
wolffd@0 13 % Input and output arguments ([]'s are optional):
wolffd@0 14 % mode (string) operation mode 'label', 'hit', 'traj', 'comet'
wolffd@0 15 % D (varies) depending on operation mode
wolffd@0 16 % In 'label' mode gives the labels
wolffd@0 17 % (struct) map struct, the .labels field of which is used
wolffd@0 18 % (cell array of strings) size munits x number_of_labels
wolffd@0 19 % In 'hit' mode gives the hit histogram(s)
wolffd@0 20 % (matrix) size munits x k, if k>1, D gives hit histograms
wolffd@0 21 % for k different sets of data (e.g. k classes).
wolffd@0 22 % In 'traj' and 'comet' modes gives the trace of the trajectory
wolffd@0 23 % (vector) size N x 1, D(1) is the current and D(end)
wolffd@0 24 % is oldest item of the trajectory
wolffd@0 25 % [argID, (string) Additional arguments are given as argID, value
wolffd@0 26 % value] (varies) pairs. Depend on the operation mode (see below).
wolffd@0 27 %
wolffd@0 28 % h (vector) handles to the created objects
wolffd@0 29 %
wolffd@0 30 % Here are the valid argument IDs and corresponding values. Most of
wolffd@0 31 % them depend on the operation mode:
wolffd@0 32 %
wolffd@0 33 % all modes
wolffd@0 34 % 'SubPlot' (vector) which subplots are affected (default: current)
wolffd@0 35 % (string) 'all': all subplots are affected
wolffd@0 36 % mode = 'label'
wolffd@0 37 % 'TextSize' (scalar) text size in points
wolffd@0 38 % 'TextColor' (string) ColorSpec, 'xor' or 'none': label color
wolffd@0 39 %
wolffd@0 40 % mode = 'hit'
wolffd@0 41 % 'EdgeColor' (string) ColorSpec, 'none'
wolffd@0 42 % 'MarkerSize' (scalar) maximum marker size
wolffd@0 43 % if k == 1,
wolffd@0 44 % 'Marker' (string) 'lattice', Matlab's built-in markerstyles, 'none'
wolffd@0 45 % 'MarkerColor'(string) Colorspec, 'none': fill color for markers
wolffd@0 46 % 'Text' (string) 'on', 'off': whether to write the number of hits
wolffd@0 47 % 'TextColor' (string) ColorSpec, 'xor': text color if Text is 'on'
wolffd@0 48 % 'TextSize' (scalar) text font size in points if Text is 'on'
wolffd@0 49 % if k > 1,
wolffd@0 50 % 'SizeFactor' (string) 'common', 'separate': size scaling
wolffd@0 51 % 'Marker' (string) 'lattice', Matlab's built-in markerstyles, 'pie', 'none'
wolffd@0 52 % (cell array) size k x 1, marker style for each histogram
wolffd@0 53 % 'MarkerColor'(string) Colorspec, 'none': fill color for markers
wolffd@0 54 % (matrix) size k x 3, color for each histogram
wolffd@0 55 %
wolffd@0 56 % mode = 'traj'
wolffd@0 57 % 'TrajWidth' (scalar) basic trajectory line width in points
wolffd@0 58 % 'WidthFactor'(string) 'hit' or 'equal': effect of hits on line width
wolffd@0 59 % 'TrajColor' (string) ColorSpec, 'xor': color for trajectory line
wolffd@0 60 % 'Marker' (string) 'lattice', Matlab's built-in markerstyles, 'none'
wolffd@0 61 % 'MarkerSize' (scalar) basic marker size (in points)
wolffd@0 62 % 'SizeFactor' (string) 'equal', 'hit' (equal size/size depends on freq.)
wolffd@0 63 % 'MarkerColor'(string) Colorspec, 'none': color of markers
wolffd@0 64 % 'EdgeColor' (string) ColorSpec, 'none': edgecolor of markers
wolffd@0 65 %
wolffd@0 66 % mode = 'comet'
wolffd@0 67 % 'Marker' (string) 'lattice', Matlab's built-in markerstyles
wolffd@0 68 % 'MarkerColor'(string) ColorSpec, 'none': color for the markers
wolffd@0 69 % (matrix) size N x 3, RGB color for each step
wolffd@0 70 % 'EdgeColor' (string) ColorSpec, 'none': edgecolor for markers
wolffd@0 71 % 'MarkerSize' (vector) size 1 x 2, size of comet core and tail
wolffd@0 72 %
wolffd@0 73 % For more help, try 'type som_show_add' or check out online documentation.
wolffd@0 74 % See also SOM_SHOW.
wolffd@0 75
wolffd@0 76 %%%%%%%%%%%% DETAILED DESCRIPTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 77 %
wolffd@0 78 % som_show_add
wolffd@0 79 %
wolffd@0 80 % PURPOSE
wolffd@0 81 %
wolffd@0 82 % Shows hits, labels and trajectories on SOM_SHOW visualization
wolffd@0 83 %
wolffd@0 84 % SYNTAX
wolffd@0 85 %
wolffd@0 86 % h = som_show_add(mode, D);
wolffd@0 87 % h = som_show_add(..., 'argID', value);
wolffd@0 88 %
wolffd@0 89 % DESCRIPTION
wolffd@0 90 %
wolffd@0 91 % The SOM_SHOW function makes the basic visualization of the SOM.
wolffd@0 92 % With SOM_SHOW_ADD one can set labels, hit histogarms or different
wolffd@0 93 % trajectories on this visualization.
wolffd@0 94 %
wolffd@0 95 % labels (mode = 'label')
wolffd@0 96 %
wolffd@0 97 % Labels are strings describing the units. They may be, e.g., a result
wolffd@0 98 % of SOM_AUTOLABEL function. Labels are centered on the unit so that
wolffd@0 99 % multiple labels are in a column.
wolffd@0 100 %
wolffd@0 101 % hit histograms (mode = 'hit')
wolffd@0 102 %
wolffd@0 103 % Hit histograms indicate how the best matching units of a data
wolffd@0 104 % set/some data sets are distribited on a SOM. The hit histogram can
wolffd@0 105 % be calculated using function SOM_HITS.
wolffd@0 106 %
wolffd@0 107 % trajectories (mode = 'traj' or mode = 'comet')
wolffd@0 108 %
wolffd@0 109 % Trajectories show the best matching units for a data set that is
wolffd@0 110 % time (or any ordered) series. It may be either a line connecting the
wolffd@0 111 % consecutive best matching units ('traj' mode) or a "comet"
wolffd@0 112 % trajectory where the current (first sample in D) best matching unit
wolffd@0 113 % has biggest marker and the oldest (last sample) has smallest
wolffd@0 114 % marker ('comet' mode).
wolffd@0 115 %
wolffd@0 116 % NOTE: that the SOM_SHOW_ADD function can only be applied to
wolffd@0 117 % figures that have been drawn by SOM_SHOW.
wolffd@0 118 %
wolffd@0 119 % KNOWN BUGS
wolffd@0 120 %
wolffd@0 121 % for 'hit' mode, if the given hit matrix is all zeros, a series of
wolffd@0 122 % error messages is generated
wolffd@0 123 %
wolffd@0 124 % REQUIRED INPUT ARGUMENTS
wolffd@0 125 %
wolffd@0 126 % mode (string) Visuzalization mode
wolffd@0 127 % 'label' map labeling
wolffd@0 128 % 'hit' hit histograms
wolffd@0 129 % 'traj' line style trajectory
wolffd@0 130 % 'comet' comet style trajectory
wolffd@0 131 %
wolffd@0 132 % D (vector, map struct, cell array of strings) Data
wolffd@0 133 %
wolffd@0 134 % The valid value of D depends on the visualization mode:
wolffd@0 135 %
wolffd@0 136 % Mode Valid D
wolffd@0 137 % 'label' map struct or Mxl cell array of strings, where
wolffd@0 138 % M is number of map units and l maximum numer of
wolffd@0 139 % labels in unit.
wolffd@0 140 %
wolffd@0 141 % 'hit' Mx1 vector or MxK matrix, where M is number of map
wolffd@0 142 % units and K is number of hit histograms (of K
wolffd@0 143 % different classes of data) to be shown
wolffd@0 144 %
wolffd@0 145 % 'comet' Lx1 vector of best matchig unit indices that have to
wolffd@0 146 % 'traj' be in range of the map that is in the figure. L is
wolffd@0 147 % the length of trajectory
wolffd@0 148 %
wolffd@0 149 % OPTIONAL INPUT ARGUMENTS
wolffd@0 150 %
wolffd@0 151 % Optional arguments must be given as 'argument identifier', value
wolffd@0 152 % -pairs. This section is divided in four parts because each mode
wolffd@0 153 % functions in a different way, though they may have same identifier
wolffd@0 154 % names.
wolffd@0 155 %
wolffd@0 156 % If user specifies an identifier that is not operational in the
wolffd@0 157 % specified mode, the functions gives a warning message. If the
wolffd@0 158 % identifier does not exist in any mode the execution is terminated
wolffd@0 159 % and an error message is returned.
wolffd@0 160 %
wolffd@0 161 % GENERAL OPTIONAL INPUT ARGUMENTS (in all modes)
wolffd@0 162 %
wolffd@0 163 % 'SubPlot' Target subplots in the figure
wolffd@0 164 % (vector) Subplots' ordinal numbers in a vector. By default
wolffd@0 165 % the target is the current subplot (see GCA).
wolffd@0 166 % (string) String 'all' means all subplots.
wolffd@0 167 %
wolffd@0 168 % 'Marker' Data marker (not in use in 'label' mode)
wolffd@0 169 % (string) 'none': sets the markers off
wolffd@0 170 % 'lattice': sets the marker shape according to the
wolffd@0 171 % lattice of the underlying map, i.e. it gives
wolffd@0 172 % rectangles if underlying map lattice is 'rect' and
wolffd@0 173 % hexagons for 'hexa', respectively
wolffd@0 174 % any of the Matlab's built-in marker styles: 'o', 's',
wolffd@0 175 % 'd', 'v', '^', '<' ,'> ', 'p', 'h', 'x', '.', '*', '+'
wolffd@0 176 %
wolffd@0 177 % NOTE that '.','x','+' or '*' are not recommended since
wolffd@0 178 % they have only edgecolor and many visualizations are
wolffd@0 179 % based on _face_ color.
wolffd@0 180 %
wolffd@0 181 % NOTE there is an important difference between built-in
wolffd@0 182 % markers. If figure size is changed the 'lattice'
wolffd@0 183 % markers are rescaled but the built-in markers stay at
wolffd@0 184 % fixed size, and consequently, the size unit for
wolffd@0 185 % 'lattice' markers is normalized but for built-in
wolffd@0 186 % markers the size is given in points. For 'lattice'
wolffd@0 187 % markers size 1 means the size of the map unit.
wolffd@0 188 %
wolffd@0 189 % NOTE that in 'hit' mode there are some additional features.
wolffd@0 190 %
wolffd@0 191 % 'EdgeColor' Sets edgecolor for the markers (not in use in 'label' mode)
wolffd@0 192 % (string) ColorSpec, e.g. 'r', gives each edge the specified color
wolffd@0 193 % 'none': sets markers edges invisible
wolffd@0 194 % Default is 'none' - except if MarkerColor is set to 'none' the
wolffd@0 195 % defaults is 'black'.
wolffd@0 196 %
wolffd@0 197 % OPTIONAL INPUT ARGUMENTS mode 'label'
wolffd@0 198 %
wolffd@0 199 % Labels are centered on the unit so that multiple labels are in
wolffd@0 200 % a single column.
wolffd@0 201 %
wolffd@0 202 % 'SubPlot' see General Optional Input Arguments
wolffd@0 203 %
wolffd@0 204 % 'TextSize' Text size for labels
wolffd@0 205 % (scalar) Text size in points. Default is 10.
wolffd@0 206 %
wolffd@0 207 % 'TextColor' Text color
wolffd@0 208 % (string) ColorSpec specifies the text color for all labels
wolffd@0 209 % 'xor': gives Matlab's "xor" text color mode where the
wolffd@0 210 % label color depends on background color
wolffd@0 211 % 'none': sets labels invisble (but creates the objects)
wolffd@0 212 %
wolffd@0 213 % OPTIONAL INPUT ARGUMENTS mode 'hit'
wolffd@0 214 %
wolffd@0 215 % The function in mode 'hit' depends on the input argument size. If
wolffd@0 216 % only one hit histogram is drawn (K==1), it is possible to show the
wolffd@0 217 % hits using numbers. This is not possible for multiple hit
wolffd@0 218 % histograms (K>1).
wolffd@0 219 %
wolffd@0 220 % 'SubPlot' see General Optional Input Arguments
wolffd@0 221 %
wolffd@0 222 % 'Marker' Marker style(s)
wolffd@0 223 % (string) As in General Optional Input Arguments. In addition
wolffd@0 224 % 'pie': sets pie charts for markers. The size of the
wolffd@0 225 % pie in each unit describes the number of total hits in the
wolffd@0 226 % unit and the share of each sector is the relative amount of
wolffd@0 227 % hits in each class (requires multiple histograms). Color for
wolffd@0 228 % each class is set by MarkerColor. Default coloring
wolffd@0 229 % is hsv(K), where K is the number of hit histograms (classes).
wolffd@0 230 % (cell array) size K x 1, of built-in marker style characters. K is
wolffd@0 231 % number of histograms (classes), i.e., same as size(D,2)
wolffd@0 232 % where D is the second input argument. Cell value is
wolffd@0 233 % valid only if multiple histograms are specified (K>1).
wolffd@0 234 %
wolffd@0 235 % NOTE if multiple histograms (classes) are specified
wolffd@0 236 % and Marker is one of the built-in marker styles or
wolffd@0 237 % 'lattice', the markers are drawn in size order from
wolffd@0 238 % largest to smallest. This insures that all markers are
wolffd@0 239 % visible (or at least their edges are). But if two
wolffd@0 240 % markers for different classes in the same node were of
wolffd@0 241 % same size, the other would be totally hidden. In order
wolffd@0 242 % to prevent this, the markers for different classes are
wolffd@0 243 % shifted different amounts from the exact centre of the
wolffd@0 244 % unit. (Evidently, if Marker is 'pie' this problem does
wolffd@0 245 % not exist.)
wolffd@0 246 %
wolffd@0 247 % Default marker is 'lattice' for one histogram and
wolffd@0 248 % 'pie' for multiple histograms.
wolffd@0 249 %
wolffd@0 250 % 'MarkerColor' Marker color(s)
wolffd@0 251 % (string) ColorSpec gives all markers the same color
wolffd@0 252 % 'none': leaves the markes transparent (only edges are visible)
wolffd@0 253 % (matrix) size K x 3, RGB triples for each histogram class
wolffd@0 254 % giving each hit histogram an own color
wolffd@0 255 %
wolffd@0 256 % NOTE that markers '*','+','x', or '.' cannot use
wolffd@0 257 % MarkerColor since these objects have no face (fill)
wolffd@0 258 % color. For them only EdgeColor matters.
wolffd@0 259 %
wolffd@0 260 % 'MarkerSize' Maximum size for marker
wolffd@0 261 % (scalar) set the _maximum_ marker size that corresponds to
wolffd@0 262 % maximum hit count. If Marker is 'pie' or 'lattice' the
wolffd@0 263 % MarkerSize is in normalized scale: 1 correspons to unit size.
wolffd@0 264 % If Marker is one of the built-in styles, MarkerSize is given
wolffd@0 265 % in points.
wolffd@0 266 %
wolffd@0 267 % Marker Default MarkerSize
wolffd@0 268 % 'lattice' 1 (normalized units)
wolffd@0 269 % 'pie' 1 (normalized units)
wolffd@0 270 % 'o','s', etc. 6 (points)
wolffd@0 271 %
wolffd@0 272 % 'SizeFactor' Defines the scaling of the marker sizes in multiple
wolffd@0 273 % histogram case (when Marker is one of the built-in marker
wolffd@0 274 % styles or 'lattice').
wolffd@0 275 % (string) 'separate' (the default) means that marker size shows
wolffd@0 276 % the share of the data which hits the unit compared to
wolffd@0 277 % amount of data in that class. That is, the size of
wolffd@0 278 % markers show the relative distribution of data on the map
wolffd@0 279 % in each class separately. The maximum size is SizeFactor.
wolffd@0 280 % 'common' means that marker size shows the distribution of
wolffd@0 281 % the data in the different classes compared to
wolffd@0 282 % _the total amount of data_.
wolffd@0 283 %
wolffd@0 284 % 'EdgeColor' Sets edgecolor for the markers, see General
wolffd@0 285 % Optional Input Arguments. Default is 'none' -
wolffd@0 286 % except if MarkerColor is 'none' or Marker is
wolffd@0 287 % 'x','*,'x', or '.'. In these cases default EdgeColor is 'black'.
wolffd@0 288 %
wolffd@0 289 % 'Text' Write/don't write the number of hits on the
wolffd@0 290 % units. This option is not in use for multiple histograms.
wolffd@0 291 % (string) 'on' or 'off' (the default)
wolffd@0 292 %
wolffd@0 293 % 'TextColor' Text color
wolffd@0 294 % (string) ColorSpec gives each letter the same color
wolffd@0 295 % 'xor' gives a "xor" coloring for the text
wolffd@0 296 %
wolffd@0 297 % 'TextSize' Text size (in points)
wolffd@0 298 % (scalar) text size in points, default is 10
wolffd@0 299 %
wolffd@0 300 % OPTIONAL INPUT ARGUMENTS mode 'traj'
wolffd@0 301 %
wolffd@0 302 % Input D is a Nx1 vector of N BMU indices that describe the trace of the
wolffd@0 303 % comet. First element D(1) is "newest" and D(end) "oldest". Note
wolffd@0 304 % that at least two indeces are expected: size of D must be at
wolffd@0 305 % least 2x1.
wolffd@0 306 %
wolffd@0 307 % 'SubPlot' see General Optional Input Arguments
wolffd@0 308 %
wolffd@0 309 % 'TrajColor' Color for trajectory line
wolffd@0 310 % (string) ColorSpec gives each marker the same color, 'w' by default
wolffd@0 311 % 'none' sets the marker fill invisible: only edges are shown
wolffd@0 312 %
wolffd@0 313 % 'TrajWidth' Maximum width of trajectory line
wolffd@0 314 % (scalar) width in points. Default is 3.
wolffd@0 315 %
wolffd@0 316 % 'WidthFactor' Shows how often edge between two units has been traversed.
wolffd@0 317 % (string) 'hit': the size of the marker shows how frequent the
wolffd@0 318 % trajectory visits the unit (TrajWidth sets the
wolffd@0 319 % maximum size). This is the default.
wolffd@0 320 % 'equal': all lines have the same width (=TrajWidth)
wolffd@0 321 %
wolffd@0 322 % 'Marker' Marker style, see General Optional Input
wolffd@0 323 % Arguments. Default is 'o'.
wolffd@0 324 %
wolffd@0 325 % NOTE Marker style 'lattice' is not valid in mode 'traj'.
wolffd@0 326 % NOTE Markers can be turned off by setting MarkerSize to zero.
wolffd@0 327 %
wolffd@0 328 % 'MarkerSize' Maximum size of markers
wolffd@0 329 % (scalar) Default is 12 (points).
wolffd@0 330 %
wolffd@0 331 % 'SizeFactor' Sets the frequency based marker size or constant marker size.
wolffd@0 332 % (string) 'hit': the size of the marker shows how frequent the
wolffd@0 333 % trajectory visits the unit (MarkerSize sets the
wolffd@0 334 % maximum size). This is the default.
wolffd@0 335 % 'equal': all markers have th esame size (=MarkerSize)
wolffd@0 336 %
wolffd@0 337 % 'MarkerColor' The fill color(s) for hit markers
wolffd@0 338 % (string) ColorSpec gives each marker the same color, default is 'w'
wolffd@0 339 % 'none' sets the marker fill invisible: only edges are shown
wolffd@0 340 %
wolffd@0 341 % NOTE markers '*','+','x', or '.' can't use MarkerColor since
wolffd@0 342 % these objects have no face (fill) color: only EdgeColor
wolffd@0 343 % matters for these markers.
wolffd@0 344 %
wolffd@0 345 % 'EdgeColor' see General Optional Input Arguments. Default is
wolffd@0 346 % 'none' - except if MarkerColor is 'none' or Marker
wolffd@0 347 % is 'x','*','x', or '.'. In these cases default
wolffd@0 348 % EdgeColor is 'white'.
wolffd@0 349 %
wolffd@0 350 % OPTIONAL INPUT ARGUMENTS mode 'comet'
wolffd@0 351 %
wolffd@0 352 % Input D is a Nx1 vector of N BMU indices that describe the trace of
wolffd@0 353 % the comet. First element D(1) is "newest" and D(end) "oldest". Note
wolffd@0 354 % that at least two indeces are expected: size of D must be at least
wolffd@0 355 % 2x1.
wolffd@0 356 %
wolffd@0 357 % 'SubPlot' see General Optional Input Arguments
wolffd@0 358 %
wolffd@0 359 % 'Marker' Marker style, see General Optional Input
wolffd@0 360 % Arguments. Default is 'lattice'.
wolffd@0 361 %
wolffd@0 362 % 'MarkerColor' The fill color(s) for comet markers
wolffd@0 363 % (string) ColorSpec gives each marker the same color, default is 'w'
wolffd@0 364 % 'none' sets the marker fill invisible: only edges are shown
wolffd@0 365 % (matrix) size N x 3, consisting of RGB triples as rows
wolffd@0 366 % sets different color for each marker. This may be
wolffd@0 367 % used to code the time series using color/grayscale.
wolffd@0 368 %
wolffd@0 369 % NOTE Markers '*','+','x', or '.' can't use MarkerColor
wolffd@0 370 % since these objects have no face (fill) color: only
wolffd@0 371 % EdgeColor matters for these markers.
wolffd@0 372 %
wolffd@0 373 % 'EdgeColor' see General Optional Input Arguments. Default is
wolffd@0 374 % 'none' - except if MarkerColor is 'none' or Marker
wolffd@0 375 % is 'x','*,'x', or '.'. In these cases default
wolffd@0 376 % EdgeColor is 'white'.
wolffd@0 377 %
wolffd@0 378 % 'MarkerSize' The size of "comet core" and tail
wolffd@0 379 % (vector) size 1 x 2: first element sets the size for the marker
wolffd@0 380 % representing D(1) and the second set size for D(end)
wolffd@0 381 % the size (area) of the markes between these changes linearly.
wolffd@0 382 % Note that size units for 'lattice' marker style are
wolffd@0 383 % normalized so that 1 means map unit size but for built-in
wolffd@0 384 % marker styles the size is given points.
wolffd@0 385 %
wolffd@0 386 % Marker default value
wolffd@0 387 % 'lattice' [0.8 0.1]
wolffd@0 388 % 'o','v', etc. [20 4]
wolffd@0 389 %
wolffd@0 390 % OUTPUT ARGUMENTS
wolffd@0 391 %
wolffd@0 392 % h (vector) handles to all objects created by the function
wolffd@0 393 %
wolffd@0 394 % OBJECT TAGS
wolffd@0 395 %
wolffd@0 396 % Field Tag in every object is set to
wolffd@0 397 %
wolffd@0 398 % 'Lab' for objects created in mode 'label'
wolffd@0 399 % 'Hit' -"- 'hit'
wolffd@0 400 % 'Traj' -"- 'traj'
wolffd@0 401 % 'Comet' -"- 'comet'
wolffd@0 402 %
wolffd@0 403 % EXAMPLES
wolffd@0 404 %
wolffd@0 405 % Not yet ready
wolffd@0 406 %
wolffd@0 407 % SEE ALSO
wolffd@0 408 %
wolffd@0 409 % som_show Basic map visualization
wolffd@0 410 % som_show_clear Clear hit marks, labels or trajectories from current figure.
wolffd@0 411
wolffd@0 412 % Copyright (c) 1999-2000 by the SOM toolbox programming team.
wolffd@0 413 % http://www.cis.hut.fi/projects/somtoolbox/
wolffd@0 414
wolffd@0 415 % Version 2.0beta Johan 131199
wolffd@0 416
wolffd@0 417 %% Check arguments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 418
wolffd@0 419 error(nargchk(2,Inf,nargin)) % check no. of input args
wolffd@0 420
wolffd@0 421 % Get data from the SOM_SHOW figure, exit if error
wolffd@0 422
wolffd@0 423 [handles,msg,lattice,msize,dim]=vis_som_show_data('all',gcf);
wolffd@0 424 error(msg);
wolffd@0 425
wolffd@0 426 munits=prod(msize);
wolffd@0 427 % Initialize some variables: these must exist later;
wolffd@0 428 % the default values are set by subfunctions
wolffd@0 429
wolffd@0 430 Property=init_properties;
wolffd@0 431 Property.handles=handles;
wolffd@0 432
wolffd@0 433 %%% Check mode and that D is of right type & size for that mode
wolffd@0 434 % mode has to be string
wolffd@0 435 if ~vis_valuetype(mode,{'string'}),
wolffd@0 436 error('String value expected for first input argument (mode).');
wolffd@0 437 else
wolffd@0 438 mode=lower(mode); % case insensitive
wolffd@0 439 mode_=mode; % 'mode' is internal variable;
wolffd@0 440 % for program constructs 'mode_' is shown to
wolffd@0 441 % user in some error messags
wolffd@0 442 end
wolffd@0 443
wolffd@0 444 switch mode % check mode
wolffd@0 445 case 'hit'
wolffd@0 446 %%% Hit histogram visualization: vector [msize k]
wolffd@0 447
wolffd@0 448 if ~vis_valuetype(D,{'nxm'}),
wolffd@0 449 error('Hit visualization: a matrix expected for data input.');
wolffd@0 450 elseif size(D,1) ~= prod(msize)
wolffd@0 451 error('Hit visualization: data and map size do not match.');
wolffd@0 452 end
wolffd@0 453 % Multiple hit histograms
wolffd@0 454 if size(D,2)>1
wolffd@0 455 mode='mhit';
wolffd@0 456 % Hit count musn't be negative
wolffd@0 457 if any(D(:)<0),
wolffd@0 458 error('Hit visualization: negative hit count in data not allowed!');
wolffd@0 459 end
wolffd@0 460 end
wolffd@0 461
wolffd@0 462 case {'traj','comet'}
wolffd@0 463 %%% Trajectory like visualizations
wolffd@0 464
wolffd@0 465 if ~vis_valuetype(D,{'nx1'}),
wolffd@0 466 error('Trajectory/Comet: a Nx1 vector expected for data input.');
wolffd@0 467 elseif any(D>prod(msize))| any(D<1),
wolffd@0 468 error('Trajectory/Comet: BMU indices out of range in data input.');
wolffd@0 469 elseif any(fix(D)~=D),
wolffd@0 470 warning('Trajectory/Comet: BMU indices not integer. Rounding...');
wolffd@0 471 elseif size(D,1)<2
wolffd@0 472 error('At least two BMU indexes expected.');
wolffd@0 473 end
wolffd@0 474
wolffd@0 475 case 'label'
wolffd@0 476 %%% Label visualizations
wolffd@0 477
wolffd@0 478 if isstruct(D), % check if D is a map
wolffd@0 479 [tmp,ok,tmp]=som_set(D);
wolffd@0 480 if all(ok) & strcmp(D.type,'som_map')
wolffd@0 481 ;
wolffd@0 482 else
wolffd@0 483 error('Map struct is invalid!');
wolffd@0 484 end
wolffd@0 485 % Size check
wolffd@0 486 if length(msize) ~= length(D.topol.msize) | ...
wolffd@0 487 munits ~= prod(D.topol.msize),
wolffd@0 488 error(['The size of the input map and the map in the figure' ...
wolffd@0 489 ' do not match.']);
wolffd@0 490 end
wolffd@0 491 D=D.labels;
wolffd@0 492 % Cell input
wolffd@0 493 elseif vis_valuetype(D,{'2Dcellarray_of_char'})
wolffd@0 494 ;
wolffd@0 495 % Char input
wolffd@0 496 elseif vis_valuetype(D,{'char_array'}),
wolffd@0 497 D=cellstr(D);
wolffd@0 498 else
wolffd@0 499 error(['Labels has to be in a map struct or in a cell array' ...
wolffd@0 500 ' of strings']);
wolffd@0 501 end
wolffd@0 502 if size(D,1) ~= munits
wolffd@0 503 error(['The number of labels does not match the size of the map' ...
wolffd@0 504 ' in the figure.']);
wolffd@0 505 end
wolffd@0 506 otherwise
wolffd@0 507 error('Invalid visualization mode.');
wolffd@0 508 end
wolffd@0 509
wolffd@0 510 if rem(length(varargin),2)
wolffd@0 511 error('Mismatch in identifier-value pairs or wrong input argument order.');
wolffd@0 512 end
wolffd@0 513
wolffd@0 514 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 515 % read in optional arguments
wolffd@0 516
wolffd@0 517 for i=1:2:length(varargin),
wolffd@0 518 %% Check that all argument types are strings
wolffd@0 519
wolffd@0 520 if ~ischar(varargin{i})
wolffd@0 521 error('Invalid identifier name or input argument order.');
wolffd@0 522 end
wolffd@0 523
wolffd@0 524 %% Lower/uppercase in identifier types doesn't matter:
wolffd@0 525
wolffd@0 526 identifier=lower(varargin{i}); % identifier (lowercase)
wolffd@0 527 value=varargin{i+1};
wolffd@0 528
wolffd@0 529 % Check property identifiers and values and store the values.
wolffd@0 530 % Struct used_in is set to initiate warning messages:
wolffd@0 531 % if a don't care propersty is set, the user is warned.
wolffd@0 532
wolffd@0 533 switch identifier
wolffd@0 534 case 'marker'
wolffd@0 535 %%% Marker for hits or trajectories
wolffd@0 536 switch mode
wolffd@0 537 case 'mhit'
wolffd@0 538 if vis_valuetype(value,{'markerstyle'}) | ...
wolffd@0 539 (vis_valuetype(value,{'string'}) & ...
wolffd@0 540 any(strcmp(value,{'lattice','pie'}))),
wolffd@0 541 ; % ok
wolffd@0 542 elseif vis_valuetype(value,{'cellcolumn_of_char'}),
wolffd@0 543 if size(value,1) ~= size(D,2)
wolffd@0 544 error([' If a cell of Markers is specified its size must be' ...
wolffd@0 545 ' number_of_hit_histograms x 1.']);
wolffd@0 546 else
wolffd@0 547 for i=1:size(D,2),
wolffd@0 548 if ~vis_valuetype(value{i},{'markerstyle'})
wolffd@0 549 error('Cell input for ''Marker'' contains invalid styles.')
wolffd@0 550 end
wolffd@0 551 end
wolffd@0 552 end
wolffd@0 553 else
wolffd@0 554 error([' Invalid ''Marker'' in case of multiple hit histograms.' ...
wolffd@0 555 char(10) ' See detailed documentation.'])
wolffd@0 556 end
wolffd@0 557 case {'comet','hit'}
wolffd@0 558 if vis_valuetype(value,{'markerstyle'}) | isempty(value),
wolffd@0 559 % ok;
wolffd@0 560 elseif ischar(value) & strcmp(value,'lattice'),
wolffd@0 561 % ok;
wolffd@0 562 else
wolffd@0 563 error(['Marker must be Matlab''s marker style, or string' ...
wolffd@0 564 ' ''lattice''.']);
wolffd@0 565 end
wolffd@0 566 case 'traj'
wolffd@0 567 if ~vis_valuetype(value,{'markerstyle'}) & ~isempty(value),
wolffd@0 568 error('In mode ''traj'' Marker must be one of Matlab''s built-in marker styles');
wolffd@0 569 end
wolffd@0 570 end
wolffd@0 571 used_in.comet=1; % Set relevance flags
wolffd@0 572 used_in.traj=1;
wolffd@0 573 used_in.label=0;
wolffd@0 574 used_in.hit=1;
wolffd@0 575 used_in.mhit=1;
wolffd@0 576
wolffd@0 577 case 'markersize'
wolffd@0 578 %%% Marker for hits or trajectories
wolffd@0 579 switch mode
wolffd@0 580 case 'comet'
wolffd@0 581 if ~vis_valuetype(value,{'1x2'}) & ~isempty(value),
wolffd@0 582 error('In mode ''comet'' MarkerSize'' must be a 1x2 vector.');
wolffd@0 583 end
wolffd@0 584 case {'hit','traj'}
wolffd@0 585 if ~vis_valuetype(value,{'1x1'}) & ~isempty(value),
wolffd@0 586 error(['In mode ''' mode_ ...
wolffd@0 587 ''' ''MarkerSize'' must be a scalar.']);
wolffd@0 588 end
wolffd@0 589 end
wolffd@0 590 used_in.comet=1; % Set relevance flags
wolffd@0 591 used_in.traj=1;
wolffd@0 592 used_in.label=0;
wolffd@0 593 used_in.hit=1;
wolffd@0 594 used_in.mhit=1;
wolffd@0 595
wolffd@0 596 case 'sizefactor'
wolffd@0 597 %%% Hit dependent size factor
wolffd@0 598 switch mode
wolffd@0 599 case 'traj'
wolffd@0 600 if ~vis_valuetype(value,{'string'}) | ...
wolffd@0 601 ~any(strcmp(value,{'hit', 'equal'})),
wolffd@0 602 error(['In mode ''traj'' ''SizeFactor'' must be ' ...
wolffd@0 603 'string ''equal'' or ''hit''.']);
wolffd@0 604 end
wolffd@0 605 case 'mhit'
wolffd@0 606 if ~vis_valuetype(value,{'string'}) | ...
wolffd@0 607 ~any(strcmp(value,{'common', 'separate'})),
wolffd@0 608 error(['In mode ''hit'' ''SizeFactor'' must be ' ...
wolffd@0 609 'string ''common'' or ''separate''.']);
wolffd@0 610 end
wolffd@0 611 end
wolffd@0 612 used_in.comet=0; % Set relevance flags
wolffd@0 613 used_in.traj=1;
wolffd@0 614 used_in.label=0;
wolffd@0 615 used_in.hit=0;
wolffd@0 616 used_in.mhit=1;
wolffd@0 617
wolffd@0 618 case 'markercolor'
wolffd@0 619 %%% Markercolor
wolffd@0 620 switch mode
wolffd@0 621 case 'comet'
wolffd@0 622 if ~vis_valuetype(value,{'colorstyle','1x3rgb'}) & ...
wolffd@0 623 ~vis_valuetype(value,{'nx3rgb',[size(D,1) 3]},'all') & ...
wolffd@0 624 ~isempty(value),
wolffd@0 625 error(['MarkerColor in mode ''comet'' must be a ColorSpec,' ...
wolffd@0 626 ' string ''none'' or Mx3 matrix of RGB triples.']);
wolffd@0 627 end
wolffd@0 628 case 'mhit'
wolffd@0 629 if ~vis_valuetype(value,{[size(D,2) 3],'nx3rgb'},'all') & ...
wolffd@0 630 ~vis_valuetype(value,{'colorstyle','1x3rgb'}),
wolffd@0 631 error([' If multiple hit histograms in mode ''hit'' are' ...
wolffd@0 632 char(10) ...
wolffd@0 633 ' given MarkerColor must be ColorSpec or a Kx3 matrix' ...
wolffd@0 634 char(10)...
wolffd@0 635 ' of RGB triples where K is the number of histograms.']);
wolffd@0 636 end
wolffd@0 637 case 'hit'
wolffd@0 638 if ~vis_valuetype(value,{'colorstyle','1x3rgb'}) & ...
wolffd@0 639 ~isempty(value),
wolffd@0 640 error(['MarkerColor in mode ''hit'' ' ...
wolffd@0 641 'must be a ColorSpec or string ''none''.']);
wolffd@0 642 end
wolffd@0 643 case 'traj'
wolffd@0 644 if ~vis_valuetype(value,{'colorstyle','1x3rgb'}) & ...
wolffd@0 645 ~isempty(value),
wolffd@0 646 error(['MarkerColor in mode ''traj'' ' ...
wolffd@0 647 'must be a ColorSpec or string ''none''.']);
wolffd@0 648 end
wolffd@0 649 end
wolffd@0 650
wolffd@0 651 used_in.comet=1; % Set relevance flags
wolffd@0 652 used_in.traj=1;
wolffd@0 653 used_in.label=0;
wolffd@0 654 used_in.hit=1;
wolffd@0 655 used_in.mhit=1;
wolffd@0 656
wolffd@0 657 case 'edgecolor'
wolffd@0 658 %%% Color for marker edges
wolffd@0 659 if ~vis_valuetype(value,{'colorstyle','1x3rgb'}) & ~isempty(value),
wolffd@0 660 error('''EdgeColor'' must be a ColorSpec or string ''none''.')
wolffd@0 661 end
wolffd@0 662
wolffd@0 663 used_in.comet=1; % Set relevance flags
wolffd@0 664 used_in.traj=1;
wolffd@0 665 used_in.label=0;
wolffd@0 666 used_in.hit=1;
wolffd@0 667 used_in.mhit=1;
wolffd@0 668
wolffd@0 669 case 'text'
wolffd@0 670 %%% Labeling for trajectories/hits
wolffd@0 671 switch mode
wolffd@0 672 case 'hit'
wolffd@0 673 %%% Hit count using numbers?
wolffd@0 674 if isempty(value),
wolffd@0 675 value='off';
wolffd@0 676 elseif vis_valuetype(value,{'string'}) & ...
wolffd@0 677 ~any(strcmp(value,{'on','off'})),
wolffd@0 678 error('Value for Text in mode ''hit'' should be ''on'' or ''off''.');
wolffd@0 679 else
wolffd@0 680 ; % ok
wolffd@0 681 end
wolffd@0 682 %case 'traj','comet'
wolffd@0 683 % if ~vis_valuetype(value,{'char_array','cellcolumn_of_char'}) & ...
wolffd@0 684 % ~isempty(value)
wolffd@0 685 % error('Value for Text is of wrong type or size.')
wolffd@0 686 % elseif ischar(value)
wolffd@0 687 % value=strcell(value) % ok, convert to cell
wolffd@0 688 % end
wolffd@0 689 % if size(traj_label,1)~=size(D,1)
wolffd@0 690 % error(['The number of labels in Text and the length of the' ...
wolffd@0 691 % ' trajectory do not match.']);
wolffd@0 692 % end
wolffd@0 693 case 'label'
wolffd@0 694 ; % not used
wolffd@0 695 end
wolffd@0 696 used_in.comet=0; % Set relevance flags
wolffd@0 697 used_in.traj=0;
wolffd@0 698 used_in.label=0;
wolffd@0 699 used_in.hit=1;
wolffd@0 700 used_in.mhit=0;
wolffd@0 701
wolffd@0 702 case 'textsize'
wolffd@0 703 %%% Text size for labels
wolffd@0 704
wolffd@0 705 if ~vis_valuetype(value,{'1x1'}) & ~isempty(value),
wolffd@0 706 error('TextSize must be scalar.');
wolffd@0 707 end
wolffd@0 708 used_in.comet=0; % Set relevance flags
wolffd@0 709 used_in.traj=0;
wolffd@0 710 used_in.label=1;
wolffd@0 711 used_in.hit=1;
wolffd@0 712 used_in.mhit=0;
wolffd@0 713
wolffd@0 714 case 'textcolor'
wolffd@0 715 %%% Color for labels
wolffd@0 716
wolffd@0 717 if ~vis_valuetype(value,{'colorstyle','1x3rgb','xor'}) & ~isempty(value),
wolffd@0 718 error('''TextColor'' must be ColorSpec, ''xor'' or ''none''.')
wolffd@0 719 end
wolffd@0 720 used_in.comet=0; % Set relevance flags
wolffd@0 721 used_in.traj=0;
wolffd@0 722 used_in.label=1;
wolffd@0 723 used_in.hit=1;
wolffd@0 724 used_in.mhit=0;
wolffd@0 725
wolffd@0 726 case 'trajwidth'
wolffd@0 727 %%% Basic line width for a line trajectory
wolffd@0 728 if ~vis_valuetype(value,{'1x1'}) & ~isempty(value),
wolffd@0 729 error('TrajWidth must be a scalar.');
wolffd@0 730 end
wolffd@0 731 used_in.comet=0; % Set relevance flags
wolffd@0 732 used_in.traj=1;
wolffd@0 733 used_in.label=0;
wolffd@0 734 used_in.hit=0;
wolffd@0 735 used_in.mhit=0;
wolffd@0 736
wolffd@0 737 case 'widthfactor'
wolffd@0 738 %%% Hit factor for a line trajectory
wolffd@0 739 if ~vis_valuetype(value,{'string'}) | ...
wolffd@0 740 ~any(strcmp(value,{'hit', 'equal'})),
wolffd@0 741 error(['In mode ''traj'' ''WidthFactor'' must be ' ...
wolffd@0 742 'string ''equal'' or ''hit''.']);
wolffd@0 743 end
wolffd@0 744 used_in.comet=0; % Set relevance flags
wolffd@0 745 used_in.traj=1;
wolffd@0 746 used_in.label=0;
wolffd@0 747 used_in.hit=0;
wolffd@0 748 used_in.mhit=0;
wolffd@0 749
wolffd@0 750 case 'trajcolor'
wolffd@0 751 %%% Color for trajectory line
wolffd@0 752
wolffd@0 753 if ~vis_valuetype(value,{'colorstyle','1x3rgb','xor'}) & ~isempty(value),
wolffd@0 754 error('''TrajColor'' must be a ColorSpec or string ''xor''.')
wolffd@0 755 end
wolffd@0 756 used_in.comet=0; % Set relevance flags
wolffd@0 757 used_in.traj=1;
wolffd@0 758 used_in.label=0;
wolffd@0 759 used_in.hit=0;
wolffd@0 760 used_in.mhit=0;
wolffd@0 761
wolffd@0 762 case 'uselabel'
wolffd@0 763 %%% Which labels to show
wolffd@0 764 error('Not yet implemented.');
wolffd@0 765
wolffd@0 766 case 'shift'
wolffd@0 767 if ~vis_valuetype(value,{'1x1'}) | ((value < 0) | (value > 1)),
wolffd@0 768 error('''Shift'' must be a scalar in range [0,1].')
wolffd@0 769 end
wolffd@0 770 used_in.comet=0; % Set relevance flags
wolffd@0 771 used_in.traj=0;
wolffd@0 772 used_in.label=0;
wolffd@0 773 used_in.hit=0;
wolffd@0 774 used_in.mhit=1;
wolffd@0 775
wolffd@0 776 case 'subplot'
wolffd@0 777 %%% The subplots which are affected
wolffd@0 778
wolffd@0 779 if vis_valuetype(value,{'1xn','nx1','string'}),
wolffd@0 780 if ischar(value),
wolffd@0 781 if ~strcmp(value,'all'),
wolffd@0 782 error('Only valid string value for subplot indices is ''all''.');
wolffd@0 783 else
wolffd@0 784 value=1:length(handles);
wolffd@0 785 end
wolffd@0 786 elseif any(value<1) | any(value>length(handles)),
wolffd@0 787 error('Subplot indices must be in range 1...number_of_subplots!');
wolffd@0 788 end
wolffd@0 789 elseif ~isempty(value)
wolffd@0 790 error('Invalid subplot indices!');
wolffd@0 791 end
wolffd@0 792 used_in.comet=1; % Set relevance flags
wolffd@0 793 used_in.traj=1;
wolffd@0 794 used_in.label=1;
wolffd@0 795 used_in.hit=1;
wolffd@0 796 used_in.mhit=1;
wolffd@0 797
wolffd@0 798 otherwise
wolffd@0 799 error([ 'Unknown identifier ''' identifier '''.']);
wolffd@0 800 end
wolffd@0 801
wolffd@0 802 % Warn user if the property that was set has no effect in the
wolffd@0 803 % selected visuzlization mode
wolffd@0 804
wolffd@0 805 if ~getfield(used_in, mode),
wolffd@0 806 warning(['Property ''' identifier ''' has no effect in mode ''' ...
wolffd@0 807 mode_ '''.']);
wolffd@0 808 else
wolffd@0 809 Property=setfield(Property,identifier,value);
wolffd@0 810 end
wolffd@0 811 end
wolffd@0 812
wolffd@0 813 % set default subplot
wolffd@0 814 if isempty(Property.subplot)
wolffd@0 815 % search the subplot number for current axis
wolffd@0 816 value=find(gca==handles);
wolffd@0 817 if isempty(value) | value>length(handles)
wolffd@0 818 error('SubPlot default value setting: current axis is not in the figure!');
wolffd@0 819 else
wolffd@0 820 Property.subplot=value;
wolffd@0 821 end
wolffd@0 822 end
wolffd@0 823
wolffd@0 824 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 825 %%%%%%% Main switch: select the right subfunction %%%%%%%%%%%%%%%%%%%
wolffd@0 826
wolffd@0 827 switch mode
wolffd@0 828 case 'hit'
wolffd@0 829 h_=hit(D, lattice, msize, Property);
wolffd@0 830 case 'mhit'
wolffd@0 831 h_=mhit(D, lattice, msize, Property);
wolffd@0 832 case 'label'
wolffd@0 833 h_=label(D, lattice, msize, Property);
wolffd@0 834 case 'traj'
wolffd@0 835 h_=traj(D, lattice, msize, Property);
wolffd@0 836 case 'comet'
wolffd@0 837 %error('Not yet implemented.');
wolffd@0 838 h_=comet(D, lattice, msize, Property);
wolffd@0 839 otherwise
wolffd@0 840 error('Whoops! Internal error: unknown mode!');
wolffd@0 841 end
wolffd@0 842
wolffd@0 843 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 844 %% Build output if necessary %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 845
wolffd@0 846 if nargout>0
wolffd@0 847 h=h_;
wolffd@0 848 end
wolffd@0 849
wolffd@0 850 %%%% SUBFUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 851
wolffd@0 852 function h_=hit(Hits, lattice, msize, Property);
wolffd@0 853
wolffd@0 854 % number of map units
wolffd@0 855 munits=prod(msize);
wolffd@0 856
wolffd@0 857 % subplots
wolffd@0 858 p=Property.subplot;
wolffd@0 859 handles=Property.handles;
wolffd@0 860
wolffd@0 861 % Set default marker
wolffd@0 862 if isempty(Property.marker),
wolffd@0 863 if strcmp(Property.text,'on')
wolffd@0 864 Property.marker='none';
wolffd@0 865 else
wolffd@0 866 Property.marker='lattice';
wolffd@0 867 end
wolffd@0 868 end
wolffd@0 869
wolffd@0 870 % Set default markersize
wolffd@0 871 if isempty(Property.markersize)
wolffd@0 872 if strcmp(Property.marker,'none'),
wolffd@0 873 warning('MarkerSize is not meaningful since Marker is set to ''none''.');
wolffd@0 874 elseif strcmp(Property.marker,'lattice'),
wolffd@0 875 Property.markersize=1; % normalized size
wolffd@0 876 else
wolffd@0 877 Property.markersize=12; % points
wolffd@0 878 end
wolffd@0 879 end
wolffd@0 880
wolffd@0 881 % Set default colors
wolffd@0 882 if ~isempty(Property.markercolor),
wolffd@0 883 if strcmp(Property.marker,'none')
wolffd@0 884 warning('MarkerColor is not used since Marker is set to ''none''.');
wolffd@0 885 Property.markercolor=[]; % not used
wolffd@0 886 else
wolffd@0 887 ; % ok
wolffd@0 888 end
wolffd@0 889 elseif any(strcmp(Property.marker,{'+','*','.','x'})),
wolffd@0 890 % these don't use fill color: 'none' will cause default
wolffd@0 891 % edgecolor to be 'k'.
wolffd@0 892 Property.markercolor='none';
wolffd@0 893 else
wolffd@0 894 Property.markercolor='k';
wolffd@0 895 end
wolffd@0 896
wolffd@0 897 if ~isempty(Property.edgecolor),
wolffd@0 898 if strcmp(Property.marker,'none')
wolffd@0 899 warning(['EdgeColor is not used since Marker is set to' ...
wolffd@0 900 ' ''none''.']);
wolffd@0 901 else
wolffd@0 902 ; %ok
wolffd@0 903 end
wolffd@0 904 elseif ~strcmp(Property.markercolor,'none'),
wolffd@0 905 Property.edgecolor='none';
wolffd@0 906 else
wolffd@0 907 Property.edgecolor='k';
wolffd@0 908 end
wolffd@0 909
wolffd@0 910 % Set default text
wolffd@0 911 if isempty(Property.text),
wolffd@0 912 Property.text='off';
wolffd@0 913 end
wolffd@0 914
wolffd@0 915 % Set default textsize
wolffd@0 916 if isempty(Property.textsize)
wolffd@0 917 Property.textsize=10;
wolffd@0 918 elseif strcmp(Property.text,'off')
wolffd@0 919 warning('TextSize not used as hits are not set to be shown as numbers.');
wolffd@0 920 end
wolffd@0 921
wolffd@0 922 % Set default textcolor
wolffd@0 923 if isempty(Property.textcolor)
wolffd@0 924 Property.textcolor='w';
wolffd@0 925 elseif strcmp(Property.text,'off')
wolffd@0 926 warning('TextColor not used as hits are not set to be shown as numbers.');
wolffd@0 927 end
wolffd@0 928
wolffd@0 929 %% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 930
wolffd@0 931 h_=[]; % this variable is for collecting the object handles
wolffd@0 932
wolffd@0 933 % Select the drawing mode
wolffd@0 934
wolffd@0 935 if ~strcmp(Property.marker,'none')
wolffd@0 936
wolffd@0 937 %%%%% Draw spots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 938
wolffd@0 939 % unit coordinates
wolffd@0 940 coord=som_vis_coords(lattice,msize);
wolffd@0 941
wolffd@0 942 % Calculate the size of the spots
wolffd@0 943 mx=max(Hits);
wolffd@0 944
wolffd@0 945 if mx==0,
wolffd@0 946 % nothing to draw!
wolffd@0 947 h_=[];
wolffd@0 948 return
wolffd@0 949 else
wolffd@0 950 Size=sqrt(Hits./mx);
wolffd@0 951 end
wolffd@0 952 % coordinates for non-zero hits (only those are drawn)
wolffd@0 953 coord=coord(Size~=0,:);
wolffd@0 954 Size=Size(Size~=0);
wolffd@0 955 N=size(Size,1);
wolffd@0 956
wolffd@0 957 % som_cplane can't draw one unit with arbitrary
wolffd@0 958 % coordinates as it its mixed with msize:
wolffd@0 959 if size(coord,1)==1 & strcmp(Property.marker,'lattice'),
wolffd@0 960 Size=[Size;Size];
wolffd@0 961 coord=[coord;coord];
wolffd@0 962 end
wolffd@0 963
wolffd@0 964 for i=1:length(p),
wolffd@0 965 % Set axes
wolffd@0 966 axes(handles(p(i)));
wolffd@0 967 % Get hold state and caxis
wolffd@0 968 memhold=ishold; cax=caxis;
wolffd@0 969 hold on;
wolffd@0 970
wolffd@0 971 switch Property.marker
wolffd@0 972 case 'lattice'
wolffd@0 973 h_(i,1)=som_cplane(lattice, coord, Property.markercolor, ...
wolffd@0 974 Property.markersize*Size);
wolffd@0 975 otherwise
wolffd@0 976 [S,m]=som_grid(lattice, [N 1],...
wolffd@0 977 'Coord',coord, ...
wolffd@0 978 'Line','none',...
wolffd@0 979 'Marker',Property.marker,...
wolffd@0 980 'MarkerColor',Property.markercolor,...
wolffd@0 981 'MarkerSize', Size*Property.markersize);
wolffd@0 982 h_=[h_;m(:)];
wolffd@0 983 end
wolffd@0 984
wolffd@0 985 % Restore hold state
wolffd@0 986 if ~memhold
wolffd@0 987 hold off;
wolffd@0 988 end
wolffd@0 989 end
wolffd@0 990
wolffd@0 991 % Set edgecolor
wolffd@0 992 if strcmp(Property.marker,'lattice')
wolffd@0 993 set(h_,'edgecolor',Property.edgecolor);
wolffd@0 994 else
wolffd@0 995 set(h_,'markeredgecolor',Property.edgecolor);
wolffd@0 996 end
wolffd@0 997 end
wolffd@0 998
wolffd@0 999 if strcmp(Property.text,'on'),
wolffd@0 1000 %%%%% Draw numbers %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1001
wolffd@0 1002 % Do numbers
wolffd@0 1003 Hits=reshape(Hits,[munits 1]);
wolffd@0 1004 labels=cell([munits 1]);
wolffd@0 1005 for i=1:length(Hits)
wolffd@0 1006 if Hits(i) % zero hit won't be shown
wolffd@0 1007 labels(i)={num2str(Hits(i))};
wolffd@0 1008 end
wolffd@0 1009 end
wolffd@0 1010
wolffd@0 1011 for i=1:length(p),
wolffd@0 1012 axes(handles(p(i))); % Set axes
wolffd@0 1013 memhold=ishold; % Get hold state
wolffd@0 1014 hold on;
wolffd@0 1015 [S,m,l,t]=som_grid(lattice, msize, ...
wolffd@0 1016 'Line','none',...
wolffd@0 1017 'Marker','none', ...
wolffd@0 1018 'Label',labels, ...
wolffd@0 1019 'LabelColor', Property.textcolor, ...
wolffd@0 1020 'LabelSize', Property.textsize);
wolffd@0 1021 % Get handles
wolffd@0 1022 h_=[h_;t(:)];
wolffd@0 1023
wolffd@0 1024 % Restore hold state and caxis
wolffd@0 1025 if ~memhold
wolffd@0 1026 hold off;
wolffd@0 1027 end
wolffd@0 1028 caxis(cax);
wolffd@0 1029 end
wolffd@0 1030
wolffd@0 1031 % Remove zero object handles (missing objects)
wolffd@0 1032 h_=setdiff(h_,0);
wolffd@0 1033 end
wolffd@0 1034
wolffd@0 1035 %% Set object tags (for som_show_clear) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1036
wolffd@0 1037 set(h_,'Tag','Hit')
wolffd@0 1038
wolffd@0 1039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1040
wolffd@0 1041 function h_=mhit(Hits, lattice, msize, Property);
wolffd@0 1042
wolffd@0 1043 % number of map units
wolffd@0 1044 munits=prod(msize);
wolffd@0 1045
wolffd@0 1046 % subplots
wolffd@0 1047 p=Property.subplot;
wolffd@0 1048 handles=Property.handles;
wolffd@0 1049
wolffd@0 1050
wolffd@0 1051 % Set default marker
wolffd@0 1052 if isempty(Property.marker),
wolffd@0 1053 Property.marker=lattice;
wolffd@0 1054 end
wolffd@0 1055
wolffd@0 1056 % variable 'mode' indicates which kind of markers are used:
wolffd@0 1057
wolffd@0 1058 if iscell(Property.marker),
wolffd@0 1059 mode='marker';
wolffd@0 1060 elseif vis_valuetype(Property.marker,{'markerstyle'}),
wolffd@0 1061 mode='marker';
wolffd@0 1062 elseif strcmp(Property.marker,'pie'),
wolffd@0 1063 mode='pie';
wolffd@0 1064 else
wolffd@0 1065 mode='lattice';
wolffd@0 1066 end
wolffd@0 1067
wolffd@0 1068 % Set default size scaling
wolffd@0 1069 if isempty(Property.sizefactor)
wolffd@0 1070 Property.sizefactor='separate';
wolffd@0 1071 end
wolffd@0 1072
wolffd@0 1073 % Set default markersize
wolffd@0 1074 if isempty(Property.markersize)
wolffd@0 1075 if any(strcmp(mode,{'lattice','pie'})),
wolffd@0 1076 Property.markersize=1; % normalized
wolffd@0 1077 else
wolffd@0 1078 Property.markersize=12; % points
wolffd@0 1079 end
wolffd@0 1080 end
wolffd@0 1081
wolffd@0 1082 % Set default colors
wolffd@0 1083
wolffd@0 1084 if isempty(Property.markercolor),
wolffd@0 1085 Property.markercolor=hsv(size(Hits,2));
wolffd@0 1086 end
wolffd@0 1087
wolffd@0 1088 if isempty(Property.edgecolor),
wolffd@0 1089 if vis_valuetype(Property.markercolor,{'none'}),
wolffd@0 1090 Property.edgecolor='k';
wolffd@0 1091 else
wolffd@0 1092 Property.edgecolor='none';
wolffd@0 1093 end
wolffd@0 1094 end
wolffd@0 1095
wolffd@0 1096 % Set default shift
wolffd@0 1097 if isempty(Property.shift)
wolffd@0 1098 Property.shift=0;
wolffd@0 1099 end
wolffd@0 1100
wolffd@0 1101 %% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1102
wolffd@0 1103 h_=[]; % this variable is for collecting the object handles
wolffd@0 1104
wolffd@0 1105 switch mode
wolffd@0 1106 case {'marker','lattice'}
wolffd@0 1107 % Number of hits histograms
wolffd@0 1108 n_Hits=size(Hits,2);
wolffd@0 1109 % Calculate the size of the spots
wolffd@0 1110
wolffd@0 1111 if strcmp(Property.sizefactor,'common')
wolffd@0 1112 mx=max(max(Hits));
wolffd@0 1113 if mx==0 % nothing to draw!
wolffd@0 1114 h_=[]; return
wolffd@0 1115 end
wolffd@0 1116 spotSize=sqrt(Hits./mx);
wolffd@0 1117 else
wolffd@0 1118 mx=repmat(max(Hits),munits,1);
wolffd@0 1119 mx(mx==0)=1; % Prevent division by zero
wolffd@0 1120 spotSize=sqrt(Hits./mx);
wolffd@0 1121 end
wolffd@0 1122
wolffd@0 1123 %%% Make spotSize
wolffd@0 1124
wolffd@0 1125 %reshape Size to a vector [spotSizeforHist(:,1); spotSizeforHist(:,2);...]
wolffd@0 1126 spotSize=spotSize(:);
wolffd@0 1127
wolffd@0 1128 % indices for non-zero hits (only those are drawn)
wolffd@0 1129 notZero=find(spotSize ~= 0);
wolffd@0 1130
wolffd@0 1131 % Drop zeros away from spotSize
wolffd@0 1132 spotSize=spotSize(notZero);
wolffd@0 1133
wolffd@0 1134 % Order spots so that bigger will be drawn first, so that they
wolffd@0 1135 % won't hide smaller ones
wolffd@0 1136 [dummy, sizeOrder]=sort(spotSize); sizeOrder=sizeOrder(end:-1:1);
wolffd@0 1137 spotSize=spotSize(sizeOrder);
wolffd@0 1138
wolffd@0 1139 %%% Make unit coordinates
wolffd@0 1140 coord=som_vis_coords(lattice,msize);
wolffd@0 1141
wolffd@0 1142 move=repmat(linspace(-.1,.1,n_Hits),size(coord,1),1)*Property.shift;
wolffd@0 1143 move=repmat(move(:),1,2);
wolffd@0 1144
wolffd@0 1145 % do n_Hits copies of unit coordinates so that they match spotSize
wolffd@0 1146 coord=repmat(coord,n_Hits,1)+move;
wolffd@0 1147
wolffd@0 1148 % Drop zeros away from coords and order
wolffd@0 1149 coord=coord(notZero,:);
wolffd@0 1150 coord=coord(sizeOrder,:);
wolffd@0 1151
wolffd@0 1152 %%% Make unit colors
wolffd@0 1153
wolffd@0 1154 if vis_valuetype(Property.markercolor,{'nx3'}),
wolffd@0 1155 % If multiple colors Copy unit colors so that they match spotSize
wolffd@0 1156 color=Property.markercolor(reshape(repmat([1:n_Hits]',1,munits)',...
wolffd@0 1157 munits*n_Hits,1),:);
wolffd@0 1158 % drop zeros away & order
wolffd@0 1159 color=color(notZero,:);
wolffd@0 1160 color=color(sizeOrder,:);
wolffd@0 1161 else
wolffd@0 1162 % only on color
wolffd@0 1163 color=Property.markercolor;
wolffd@0 1164 end
wolffd@0 1165
wolffd@0 1166 %%% Make unit markers
wolffd@0 1167
wolffd@0 1168 if iscell(Property.marker),
wolffd@0 1169 %marker shows class:
wolffd@0 1170 marker=char(Property.marker);
wolffd@0 1171 marker=marker(reshape(repmat([1:n_Hits]',1,munits)',...
wolffd@0 1172 munits*n_Hits,1),:);
wolffd@0 1173 % Drop zeros, order & make to cell array (for som_grid)
wolffd@0 1174 marker=marker(notZero,:);
wolffd@0 1175 marker=cellstr(marker(sizeOrder,:));
wolffd@0 1176 else
wolffd@0 1177 marker=Property.marker;
wolffd@0 1178 end
wolffd@0 1179
wolffd@0 1180 % som_cplane can't draw one unit with arbitrary
wolffd@0 1181 % coordinates as it its mixed with msize:
wolffd@0 1182 if size(coord,1)==1 & strcmp(mode,'lattice'),
wolffd@0 1183 spotSize = [spotSize; spotSize];
wolffd@0 1184 coord = [coord; coord];
wolffd@0 1185 end
wolffd@0 1186
wolffd@0 1187 N=length(notZero); % for som_grid visuzalization routine
wolffd@0 1188 case 'pie'
wolffd@0 1189 % marker 'pie' requires size parameter totHits
wolffd@0 1190 if strcmp(mode,'pie')
wolffd@0 1191 coord=som_vis_coords(lattice, msize);
wolffd@0 1192 notZero=sum(Hits,2)>0;
wolffd@0 1193 Hits=Hits(notZero,:);
wolffd@0 1194 coord=coord(notZero,:);
wolffd@0 1195 N=size(notZero,1);
wolffd@0 1196 totHits=sqrt(sum(Hits,2)./max(sum(Hits,2)));
wolffd@0 1197 end
wolffd@0 1198
wolffd@0 1199 % som_pieplane can't draw one unit with arbitrary
wolffd@0 1200 % coordinates as it its mixed with msize:
wolffd@0 1201 if size(coord,1)==1,
wolffd@0 1202 Hits= [Hits; Hits];
wolffd@0 1203 coord = [coord; coord];
wolffd@0 1204 end
wolffd@0 1205 otherwise
wolffd@0 1206 error('Whoops: internal error. Bad mode in subfunction mhit');
wolffd@0 1207 end
wolffd@0 1208
wolffd@0 1209 for i=1:length(p), %%% Main loop begins
wolffd@0 1210 % Set axis
wolffd@0 1211 axes(handles(p(i)));
wolffd@0 1212 % Get hold state and caxis
wolffd@0 1213 memhold=ishold; cax=caxis;
wolffd@0 1214 hold on;
wolffd@0 1215
wolffd@0 1216 switch mode
wolffd@0 1217 case 'lattice'
wolffd@0 1218 h_(i,1)=som_cplane(lattice, coord, color, spotSize*Property.markersize);
wolffd@0 1219 case 'marker'
wolffd@0 1220 [S,m]=som_grid(lattice, [N 1],...
wolffd@0 1221 'Coord',coord, ...
wolffd@0 1222 'Line','none',...
wolffd@0 1223 'Marker',marker,...
wolffd@0 1224 'MarkerColor',color,...
wolffd@0 1225 'MarkerSize', spotSize*Property.markersize);
wolffd@0 1226 h_=[h_;m(:)];
wolffd@0 1227 case 'pie'
wolffd@0 1228 h_(i)=som_pieplane(lattice, coord, ...
wolffd@0 1229 Hits, Property.markercolor, ...
wolffd@0 1230 totHits*Property.markersize);
wolffd@0 1231 end
wolffd@0 1232
wolffd@0 1233 % Restore hold state and caxis
wolffd@0 1234 if ~memhold
wolffd@0 1235 hold off;
wolffd@0 1236 end
wolffd@0 1237 caxis(cax);
wolffd@0 1238 end
wolffd@0 1239
wolffd@0 1240 % Set edgecolor
wolffd@0 1241 if any(strcmp(mode,{'lattice','pie'})),
wolffd@0 1242 set(h_,'edgecolor',Property.edgecolor);
wolffd@0 1243 else
wolffd@0 1244 set(h_,'markeredgecolor',Property.edgecolor);
wolffd@0 1245 end
wolffd@0 1246
wolffd@0 1247 %% Set object tags (for som_show_clear) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1248
wolffd@0 1249 set(h_,'Tag','Hit')
wolffd@0 1250
wolffd@0 1251 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1252
wolffd@0 1253 function h_=label(Labels, lattice, msize, Property)
wolffd@0 1254
wolffd@0 1255 % number of map units
wolffd@0 1256 munits=prod(msize);
wolffd@0 1257
wolffd@0 1258 % subplots and handles
wolffd@0 1259 p=Property.subplot;
wolffd@0 1260 handles= Property.handles;
wolffd@0 1261
wolffd@0 1262 % Set default text size
wolffd@0 1263 if isempty(Property.textsize) % default point size
wolffd@0 1264 Property.textsize=10;
wolffd@0 1265 end
wolffd@0 1266
wolffd@0 1267 % Check color/set default
wolffd@0 1268 if isempty(Property.textcolor),
wolffd@0 1269 Property.textcolor='k';
wolffd@0 1270 end
wolffd@0 1271
wolffd@0 1272 % handles will be collected in h_ for output
wolffd@0 1273 h_=[];
wolffd@0 1274
wolffd@0 1275 %%% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1276
wolffd@0 1277 for i=1:length(p);
wolffd@0 1278 % set axes
wolffd@0 1279 axes(handles(p(i)));
wolffd@0 1280 % store hold state and caxis (for some reason matlab may
wolffd@0 1281 % change caxis(!?)
wolffd@0 1282 memhold=ishold;
wolffd@0 1283 hold on;
wolffd@0 1284 cax=caxis;
wolffd@0 1285
wolffd@0 1286 % Write labels
wolffd@0 1287 [S,m,l,t]=som_grid(lattice, msize, ...
wolffd@0 1288 'Line','none', ...
wolffd@0 1289 'Marker', 'none', ...
wolffd@0 1290 'Label', Labels, ...
wolffd@0 1291 'LabelColor', Property.textcolor, ...
wolffd@0 1292 'LabelSize', Property.textsize);
wolffd@0 1293 % Get handles
wolffd@0 1294 h_=[h_;m(:);l(:);t(:)];
wolffd@0 1295
wolffd@0 1296 % reset hold state and caxis
wolffd@0 1297 if ~memhold
wolffd@0 1298 hold off;
wolffd@0 1299 end
wolffd@0 1300 caxis(cax);
wolffd@0 1301 end
wolffd@0 1302
wolffd@0 1303 %%% Set object tags %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1304
wolffd@0 1305 set(h_,'Tag','Lab');
wolffd@0 1306
wolffd@0 1307 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1308
wolffd@0 1309 function h_=traj(bmu, lattice, msize, Property)
wolffd@0 1310
wolffd@0 1311 % number of map units
wolffd@0 1312 munits=prod(msize);
wolffd@0 1313
wolffd@0 1314 % subplots and handles
wolffd@0 1315 p=Property.subplot;
wolffd@0 1316 handles=Property.handles;
wolffd@0 1317
wolffd@0 1318 % Set default text color
wolffd@0 1319 %if isempty(Property.textcolor),
wolffd@0 1320 % Property.textcolor='k';
wolffd@0 1321 %end
wolffd@0 1322
wolffd@0 1323 % Set default text size
wolffd@0 1324 %if isempty(Property.textsize)
wolffd@0 1325 % Property.textsize=10;
wolffd@0 1326 %end
wolffd@0 1327
wolffd@0 1328 % Set default marker
wolffd@0 1329 if isempty(Property.marker)
wolffd@0 1330 Property.marker='o';
wolffd@0 1331 end
wolffd@0 1332
wolffd@0 1333 % Set default markersize
wolffd@0 1334 if isempty(Property.markersize)
wolffd@0 1335 Property.markersize=10;
wolffd@0 1336 end
wolffd@0 1337
wolffd@0 1338 % Set default markercolor
wolffd@0 1339 if isempty(Property.markercolor)
wolffd@0 1340 Property.markercolor='w';
wolffd@0 1341 end
wolffd@0 1342
wolffd@0 1343 % Set default sizefactor
wolffd@0 1344 if isempty(Property.sizefactor)
wolffd@0 1345 %Property.sizefactor=0;
wolffd@0 1346 Property.sizefactor='hit';
wolffd@0 1347 end
wolffd@0 1348
wolffd@0 1349 % Set default trajwidth
wolffd@0 1350 if isempty(Property.trajwidth)
wolffd@0 1351 Property.trajwidth=3;
wolffd@0 1352 end
wolffd@0 1353
wolffd@0 1354 % Set default widthfactor
wolffd@0 1355 if isempty(Property.widthfactor)
wolffd@0 1356 Property.widthfactor='hit';
wolffd@0 1357 end
wolffd@0 1358
wolffd@0 1359 % Set default trajcolor
wolffd@0 1360 if isempty(Property.trajcolor)
wolffd@0 1361 Property.trajcolor='w';
wolffd@0 1362 end
wolffd@0 1363
wolffd@0 1364 % if no labels, do a empty cell array for syntax reasons
wolffd@0 1365 %if isempty(Property.text),
wolffd@0 1366 % Property.text=cell(munits,1);
wolffd@0 1367 %end
wolffd@0 1368
wolffd@0 1369 h_=[]; % handles will be collected in h_ for output
wolffd@0 1370 l=length(bmu); % length of trajectory
wolffd@0 1371 C=sparse(munits, munits); % init a connection matrix
wolffd@0 1372
wolffd@0 1373 %%%%%% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1374
wolffd@0 1375 % Calculate the connection matrix that describes the trajectory
wolffd@0 1376 for i=1:l-1,
wolffd@0 1377 % The following if structure removes the possible redundancy due
wolffd@0 1378 % to travels in both directions between two nodes of trajectory
wolffd@0 1379 % (i.e. reflexivity)
wolffd@0 1380 I=bmu(i+1);J=bmu(i);
wolffd@0 1381 %if bmu(i)>bmu(i+1)
wolffd@0 1382
wolffd@0 1383 %else
wolffd@0 1384 % I=bmu(i);J=bmu(i+1);
wolffd@0 1385 %end
wolffd@0 1386 C(I,J)=C(I,J)+1;
wolffd@0 1387 end
wolffd@0 1388
wolffd@0 1389 % transitive connections are equal
wolffd@0 1390 C=C+C';
wolffd@0 1391 % drop reflexive conncetions away
wolffd@0 1392 C=spdiags(zeros(munits,1),0,C);
wolffd@0 1393
wolffd@0 1394 % Do labels of trajectory nodes
wolffd@0 1395
wolffd@0 1396 %traj_lab=cell(munits,1);
wolffd@0 1397 hits=zeros(munits,1);
wolffd@0 1398
wolffd@0 1399 for i=1:l,
wolffd@0 1400 % traj_lab{bmu(i)}=strvcat(traj_lab{bmu(i)},Property.text{i});
wolffd@0 1401 hits(bmu(i))=(hits(bmu(i))+1);
wolffd@0 1402 end
wolffd@0 1403
wolffd@0 1404 % Calculate unit coordinates
wolffd@0 1405 unit_coord=som_vis_coords(lattice, msize);
wolffd@0 1406
wolffd@0 1407 % Calculate line width
wolffd@0 1408 if strcmp(Property.widthfactor,'equal')
wolffd@0 1409 TrajWidth=(C>0)*Property.trajwidth;
wolffd@0 1410 else
wolffd@0 1411 TrajWidth=Property.trajwidth.*sqrt(C./max(max(C)));
wolffd@0 1412 end
wolffd@0 1413
wolffd@0 1414 % Calculate marker sizes
wolffd@0 1415 if strcmp(Property.sizefactor,'hit')
wolffd@0 1416 MarkerSize=Property.markersize*sqrt(hits/max(hits));
wolffd@0 1417 else
wolffd@0 1418 MarkerSize=Property.markersize*(hits>0);
wolffd@0 1419 end
wolffd@0 1420
wolffd@0 1421 for i=1:length(p),
wolffd@0 1422 axes(handles(p(i)));
wolffd@0 1423 % Get hold state and caxis
wolffd@0 1424 memhold=ishold; cax=caxis;
wolffd@0 1425 hold on;
wolffd@0 1426
wolffd@0 1427 %'Label', traj_lab, ...
wolffd@0 1428 %'LabelColor', Property.textcolor, ...
wolffd@0 1429 %'LabelSize', Property.textsize, ...
wolffd@0 1430
wolffd@0 1431 % Draw
wolffd@0 1432 [S,m,l,t,s]=som_grid(C,msize,'coord',unit_coord,...
wolffd@0 1433 'Line','-', ...
wolffd@0 1434 'LineColor', Property.trajcolor, ...
wolffd@0 1435 'LineWidth', TrajWidth, ...
wolffd@0 1436 'Marker', Property.marker, ...
wolffd@0 1437 'MarkerColor', Property.markercolor, ...
wolffd@0 1438 'MarkerSize', MarkerSize);
wolffd@0 1439
wolffd@0 1440 % Restore hold state and caxis
wolffd@0 1441 if ~memhold
wolffd@0 1442 hold off;
wolffd@0 1443 end
wolffd@0 1444 caxis(cax);
wolffd@0 1445 % Get handles
wolffd@0 1446 h_=[h_;m(:);l(:);t(:);s(:)];
wolffd@0 1447 end
wolffd@0 1448
wolffd@0 1449 %% Set object tags %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1450
wolffd@0 1451 set(h_,'Tag','Traj');
wolffd@0 1452
wolffd@0 1453 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1454
wolffd@0 1455 function h_=comet(bmu, lattice, msize, Property)
wolffd@0 1456
wolffd@0 1457 % number of map units
wolffd@0 1458 munits=prod(msize);
wolffd@0 1459
wolffd@0 1460 % subplots and handles
wolffd@0 1461 p=Property.subplot;
wolffd@0 1462 handles=Property.handles;
wolffd@0 1463
wolffd@0 1464 % Set default text color
wolffd@0 1465 %if isempty(Property.textcolor),
wolffd@0 1466 % Property.textcolor='k';
wolffd@0 1467 %end
wolffd@0 1468
wolffd@0 1469 %% Set default text size
wolffd@0 1470 %if isempty(Property.textsize)
wolffd@0 1471 % Property.textsize=10;
wolffd@0 1472 %end
wolffd@0 1473
wolffd@0 1474 % Set default marker
wolffd@0 1475 if isempty(Property.marker)
wolffd@0 1476 Property.marker='o';
wolffd@0 1477 end
wolffd@0 1478
wolffd@0 1479 % Set default markersize
wolffd@0 1480 if isempty(Property.markersize),
wolffd@0 1481 if strcmp(Property.marker,'lattice'),
wolffd@0 1482 Property.markersize=linspace(0.8,0.1,length(bmu))';
wolffd@0 1483 else
wolffd@0 1484 Property.markersize=sqrt(linspace(400,16,length(bmu)))';
wolffd@0 1485 end
wolffd@0 1486 else
wolffd@0 1487 if strcmp(Property.marker,'lattice'),
wolffd@0 1488 Property.markersize=linspace(Property.markersize(1),...
wolffd@0 1489 Property.markersize(2), ...
wolffd@0 1490 length(bmu))';
wolffd@0 1491 else
wolffd@0 1492 Property.markersize=sqrt(linspace(Property.markersize(1).^2,...
wolffd@0 1493 Property.markersize(2).^2, ...
wolffd@0 1494 length(bmu)))';
wolffd@0 1495
wolffd@0 1496 end
wolffd@0 1497 end
wolffd@0 1498
wolffd@0 1499 % Set default markercolor
wolffd@0 1500 if isempty(Property.markercolor)
wolffd@0 1501 Property.markercolor='w';
wolffd@0 1502 end
wolffd@0 1503
wolffd@0 1504 % Set default edgecolor
wolffd@0 1505 if isempty(Property.edgecolor),
wolffd@0 1506 if vis_valuetype(Property.markercolor,{'nx3rgb'}),
wolffd@0 1507 Property.edgecolor='none';
wolffd@0 1508 else
wolffd@0 1509 Property.edgecolor=Property.markercolor;
wolffd@0 1510 end
wolffd@0 1511 end
wolffd@0 1512
wolffd@0 1513 h_=[];l_=[]; % handles will be collected in h_ for output
wolffd@0 1514 N_bmus=length(bmu); % length of trajectory
wolffd@0 1515
wolffd@0 1516 % if no labels, do a empty cell array for syntax reasons
wolffd@0 1517 %if isempty(Property.text),
wolffd@0 1518 % Property.text=cell(N_bmus,1);
wolffd@0 1519 %end
wolffd@0 1520
wolffd@0 1521 %%%%%% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1522
wolffd@0 1523 % Calculate unit coordinates for trajectory points
wolffd@0 1524 unit_coord=som_vis_coords(lattice, msize);
wolffd@0 1525 coord=unit_coord(bmu,:);
wolffd@0 1526
wolffd@0 1527 % Make labels for the _unique_ units that the comet hits
wolffd@0 1528
wolffd@0 1529 unique_bmu=unique(bmu); % count units
wolffd@0 1530 %N_labels=length(unique_bmu);
wolffd@0 1531 %traj_lab=cell(N_labels,1); % cell for labels
wolffd@0 1532 %label_coord=unit_coord(unique_bmu,:); % label coordinates
wolffd@0 1533
wolffd@0 1534 % Make labels
wolffd@0 1535 %for i=1:N_bmus,
wolffd@0 1536 % index=find(unique_bmu==bmu(i));
wolffd@0 1537 % traj_lab{index}=strvcat(traj_lab{index},Property.text{i});
wolffd@0 1538 %end
wolffd@0 1539
wolffd@0 1540 %Main loop for drawing comets
wolffd@0 1541 for i=1:length(p),
wolffd@0 1542 % set axis
wolffd@0 1543 axes(handles(p(i)));
wolffd@0 1544
wolffd@0 1545 % Get hold state and caxis
wolffd@0 1546 memhold=ishold; cax=caxis;
wolffd@0 1547 hold on;
wolffd@0 1548
wolffd@0 1549 if strcmp(Property.marker,'lattice'),
wolffd@0 1550 % Draw: marker is a patch ('hexa','rect')
wolffd@0 1551 l_=som_cplane(lattice, coord, Property.markercolor, ...
wolffd@0 1552 Property.markersize);
wolffd@0 1553
wolffd@0 1554 % Set edgecolor
wolffd@0 1555 set(l_,'edgecolor',Property.edgecolor);
wolffd@0 1556 else
wolffd@0 1557 % Draw: other markers than 'hexa' or 'rect'
wolffd@0 1558 [S,m,l,t,s]=som_grid(lattice, [N_bmus 1], 'coord', coord,...
wolffd@0 1559 'Line','none', ...
wolffd@0 1560 'Marker', Property.marker, ...
wolffd@0 1561 'MarkerColor', Property.markercolor, ...
wolffd@0 1562 'MarkerSize',Property.markersize);
wolffd@0 1563
wolffd@0 1564 % Set edgecolor
wolffd@0 1565 set(m, 'markeredgecolor', Property.edgecolor);
wolffd@0 1566
wolffd@0 1567 % Get handles from markers
wolffd@0 1568 h_=[h_;l_(:);m(:);l(:);t(:);s(:)];
wolffd@0 1569 end
wolffd@0 1570
wolffd@0 1571 % Set labels
wolffd@0 1572 %[S,m,l,t,s]=som_grid(lattice, [N_labels 1], 'coord', label_coord,...
wolffd@0 1573 % 'Marker','none','Line','none',...
wolffd@0 1574 % 'Label', traj_lab, ...
wolffd@0 1575 % 'LabelColor', Property.textcolor, ...
wolffd@0 1576 % 'LabelSize', Property.textsize);
wolffd@0 1577 % Get handles from labels
wolffd@0 1578 %h_=[h_;m(:);l(:);t(:);s(:)];
wolffd@0 1579
wolffd@0 1580 % Restore hold state and caxis
wolffd@0 1581 if ~memhold
wolffd@0 1582 hold off;
wolffd@0 1583 end
wolffd@0 1584 caxis(cax);
wolffd@0 1585 end
wolffd@0 1586
wolffd@0 1587 %% Set object tags %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1588
wolffd@0 1589 set(h_,'Tag','Comet');
wolffd@0 1590
wolffd@0 1591 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 1592
wolffd@0 1593
wolffd@0 1594 function P=init_properties;
wolffd@0 1595
wolffd@0 1596 % Initialize an empty property struct
wolffd@0 1597
wolffd@0 1598 P.marker=[];
wolffd@0 1599 P.markersize=[];
wolffd@0 1600 P.sizefactor=[];
wolffd@0 1601 P.markercolor=[];
wolffd@0 1602 P.edgecolor=[];
wolffd@0 1603 P.trajwidth=[];
wolffd@0 1604 P.widthfactor=[];
wolffd@0 1605 P.trajcolor=[];
wolffd@0 1606 P.text=[];
wolffd@0 1607 P.textsize=[];
wolffd@0 1608 P.textcolor=[];
wolffd@0 1609 P.subplot=[];
wolffd@0 1610 P.shift=[];