Description Usage Arguments Details Value See Also Examples
Plots data output from one of trackter
's kin
functions using ggplot2
. Useful for quickly visualizing results from kin
functions. Data and geometries include body-contour polygons with midline points, head or fin points, both midline and head points, or none or all of these. Optionally builds and saves an animation of data with reference to frame from kin
data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
kin |
a list of data returned from |
frames |
integer, a vector for frames within the data (a column common to all |
under |
character, the data to plot under |
over |
character, the data to plot over the contour(s). Must be either 'kin.dat', 'midline', 'both', 'fin', 'fin.pt', 'all', or 'none'. See Details. |
zoom |
logical, should the plotted area zoom to the extents of the contours. See Detail. |
animate |
logical, should an animation be plotted to the graphics device with state changes reflected by |
shadow |
logical,should |
alpha |
numeric, the opacity of geometries in previous frames during animation. Ignored if |
fps |
integer, the play back speed of animation in frames per second. Ignored if |
save |
logical, should the animation be saved as a GIF. Ignored if |
filename |
character, the name given to the GIF file. Ignored if |
out.dir |
character, the file path of the directory to which the GIF file is saved. Ignored if |
... |
other arguments to be passed to midline and head point geometries, e.g. 'size', 'color'. |
Simply plots 2D dimensional data over contours retrieved from kin
functions. May be useful in quickly assesses their results. The under
layer can be one of the named contour data tables in lists returned by the kin
functions kin.search
,kin.simple
, kin.free
, or fin.kin
. The overlayed data layer specified by over
are non-contour data from the kin
functions.
If the list specified by 'kin' is from kin.search
,kin.simple
, or kin.free
, 'over' must be 'cont' or 'cont.sm' and under one of 'midline','kin', 'none' or 'both'. 'midline' will produce the smoothed midline coordinates.
If the list specified by 'kin' is from fin.kin
, 'over' must be 'cont' or 'comp' and under one of 'midline','fin', 'fin.pts', 'none' or 'all'.
Animations are produced with gganimate
and optionally saved as a GIF with anim_save
using the default gifski_renderer()
.
A ggplot
printed to the graphics device, a gganimate
object plotted to graphics device, or a GIF file saved to a local directory specified in out.dir
.
geom_point
, geom_polygon
,gganimate
, kin.free
, kin.search
, kin.simple
,fin.kin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ## Not run:
#animate a ropefish swimming with its midline
#download example avi and place in subdirectory
f <- "https://github.com/ckenaley/exampledata/blob/master/ropefish.avi?raw=true"
download.file(f, paste0(tempdir(),"/ropefish.avi"))
dir.create(paste0(tempdir(),"/images"))
vid.to.images(paste0(tempdir(),"/ropefish.avi"), out.dir = paste0(tempdir(),"/images"))
kin <- kin.free(image.dir =paste0(tempdir(),"/images"),
par=TRUE,
ml.smooth=list("spline",0.9),
thr = "otsu",
size.min=0.01,
red=0.5
)
gg.overlay(kin=kin,
frames=seq(20,320,20),
under="cont.sm",
over="midline",
size=1,
animate=TRUE,
col="red",
fps=10)
#clean up
unlink(paste0(tempdir(),"/images"),recursive=TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.