visHexAnimate
is supposed to animate multiple component planes
of a supra-hexagonal grid. The output can be a pdf file containing a
list of frames/images, a mp4 video file or a gif file. To support video
output file, the software 'ffmpeg' must be first installed (also put
its path into the system PATH variable; see Note). To support gif
output file, the software 'ImageMagick' must be first installed (also
put its path into the system PATH variable; see Note).
visHexAnimate(sMap, which.components = NULL, filename = "visHexAnimate", filetype = c("pdf", "mp4", "gif"), image.type = c("jpg", "png"), sec_per_frame = 1, margin = rep(0.1, 4), height = 7, title.rotate = 0, title.xy = c(0.45, 1), colormap = c("bwr", "jet", "gbr", "wyr", "br", "yr", "rainbow", "wb"), ncolors = 40, zlim = NULL, border.color = "transparent", gp = grid::gpar())
If specifying the output file name (see argument 'filename' above), the output file is either 'filename.pdf' or 'filename.mp4' or 'filename.gif' in the current working directory. If no output file name specified, by default the output file is either 'visHexAnimate.pdf' or 'visHexAnimate.mp4' or 'visHexAnimate.gif'
When producing mp4 video, this function requires the installation of the software 'ffmpeg' at https://www.ffmpeg.org. Shell command lines for ffmpeg installation in Terminal (for both Linux and Mac) are:
wget -O ffmpeg.tar.gz
http://www.ffmpeg.org/releases/ffmpeg-2.7.1.tar.gz
mkdir ~/ffmpeg | tar xvfz ffmpeg.tar.gz -C ~/ffmpeg
--strip-components=1
cd ffmpeg
./configure --disable-yasm
./configure --disable-yasm --prefix=$HOME/ffmpeg
make
make install
export PATH=$HOME/ffmpeg:$PATH
ffmpeg -h
When producing gif file, this function requires the installation of the software 'ImageMagick' at http://www.imagemagick.org. Shell command lines for ImageMagick installation in Terminal are:
wget
http://www.imagemagick.org/download/ImageMagick.tar.gz
mkdir ~/ImageMagick | tar xvzf ImageMagick.tar.gz -C
~/ImageMagick --strip-components=1
cd ImageMagick
./configure --prefix=$HOME/ImageMagick
make
make install
export MAGICK_HOME=$HOME/ImageMagick
export PATH=$MAGICK_HOME/bin:$PATH
export
LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$MAGICK_HOME/lib
For Mac: export MAGICK_HOME=$HOME/ImageMagick
export PATH=$MAGICK_HOME/bin:$PATH
export
DYLD_LIBRARY_PATH=$MAGICK_HOME/lib/
convert -list configure
identify -list
format
libjpeg
and
libpng
are installed. If NOT, for Mac try this: brew
install libjpeg libpng
To check whether ImageMagick does work,
please get additional information from: identify -list format
convert -list configure
On details, please refer to
http://www.imagemagick.org/script/advanced-unix-installation.php
# 1) generate data with an iid matrix of 1000 x 3 data <- cbind(matrix(rnorm(1000*3,mean=0,sd=1), nrow=1000, ncol=3), matrix(rnorm(1000*3,mean=0.5,sd=1), nrow=1000, ncol=3), matrix(rnorm(1000*3,mean=-0.5,sd=1), nrow=1000, ncol=3)) colnames(data) <- c("S1","S1","S1","S2","S2","S2","S3","S3","S3") # 2) sMap resulted from using by default setup sMap <- sPipeline(data=data)Start at 2018-01-18 16:56:21 First, define topology of a map grid (2018-01-18 16:56:21)... Second, initialise the codebook matrix (169 X 9) using 'linear' initialisation, given a topology and input data (2018-01-18 16:56:21)... Third, get training at the rough stage (2018-01-18 16:56:21)... 1 out of 2 (2018-01-18 16:56:21) updated (2018-01-18 16:56:21) 2 out of 2 (2018-01-18 16:56:21) updated (2018-01-18 16:56:21) Fourth, get training at the finetune stage (2018-01-18 16:56:21)... 1 out of 7 (2018-01-18 16:56:21) updated (2018-01-18 16:56:21) 2 out of 7 (2018-01-18 16:56:21) updated (2018-01-18 16:56:21) 3 out of 7 (2018-01-18 16:56:21) updated (2018-01-18 16:56:21) 4 out of 7 (2018-01-18 16:56:21) updated (2018-01-18 16:56:22) 5 out of 7 (2018-01-18 16:56:22) updated (2018-01-18 16:56:22) 6 out of 7 (2018-01-18 16:56:22) updated (2018-01-18 16:56:22) 7 out of 7 (2018-01-18 16:56:22) updated (2018-01-18 16:56:22) Next, identify the best-matching hexagon/rectangle for the input data (2018-01-18 16:56:22)... Finally, append the response data (hits and mqe) into the sMap object (2018-01-18 16:56:22)... Below are the summaries of the training results: dimension of input data: 1000x9 xy-dimension of map grid: xdim=15, ydim=15, r=8 grid lattice: hexa grid shape: suprahex dimension of grid coord: 169x2 initialisation method: linear dimension of codebook matrix: 169x9 mean quantization error: 4.20946606456718 Below are the details of trainology: training algorithm: batch alpha type: invert training neighborhood kernel: gaussian trainlength (x input data length): 2 at rough stage; 7 at finetune stage radius (at rough stage): from 4 to 1 radius (at finetune stage): from 1 to 1 End at 2018-01-18 16:56:22 Runtime in total is: 1 secs# 3) animate sMap # output as a pdf file visHexAnimate(sMap, filename="visHexAnimate", filetype="pdf")Congratulations! A file 'visHexAnimate.pdf' (in the directory /Users/hfang/Sites/SUPERFAMILY/supraHex) has been created!# output as a mp4 file visHexAnimate(sMap, filename="visHexAnimate", filetype="mp4")Executing this command: 'ffmpeg -y -v quiet -r 1 -i /var/folders/wq/4cmk3m511571471lj67cpmbh0000gn/T//RtmpHESjyI/Rplot%06d.jpg -q:v 1 /var/folders/wq/4cmk3m511571471lj67cpmbh0000gn/T//RtmpHESjyI/visHexAnimate.mp4' Congratulations! A file 'visHexAnimate.mp4' (in the directory /Users/hfang/Sites/SUPERFAMILY/supraHex) has been created!# output as a gif file visHexAnimate(sMap, filename="visHexAnimate", filetype="gif")Executing this command: 'convert -delay 100 /var/folders/wq/4cmk3m511571471lj67cpmbh0000gn/T//RtmpHESjyI/Rplot*.jpg /var/folders/wq/4cmk3m511571471lj67cpmbh0000gn/T//RtmpHESjyI/visHexAnimate.gif' Congratulations! A file 'visHexAnimate.gif' (in the directory /Users/hfang/Sites/SUPERFAMILY/supraHex) has been created!