All Projects → thomasp85 → Tweenr

thomasp85 / Tweenr

Licence: other
Interpolate your data

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to Tweenr

Gganimate
A Grammar of Animated Graphics
Stars: ✭ 1,744 (+363.83%)
Mutual labels:  rstats, transition
Ggthemr
Themes for ggplot2.
Stars: ✭ 697 (+85.37%)
Mutual labels:  rstats, plotting
Geoviews
Simple, concise geographical visualization in Python
Stars: ✭ 338 (-10.11%)
Mutual labels:  plotting
Hvplot
A high-level plotting API for pandas, dask, xarray, and networkx built on HoloViews
Stars: ✭ 368 (-2.13%)
Mutual labels:  plotting
Stplanr
Sustainable transport planning with R
Stars: ✭ 352 (-6.38%)
Mutual labels:  rstats
Music Player
From UI Proposal to Code 🎶▶️
Stars: ✭ 3,459 (+819.95%)
Mutual labels:  transition
Assertr
Assertive programming for R analysis pipelines
Stars: ✭ 355 (-5.59%)
Mutual labels:  rstats
Kompass
Kotlin Multiplatform Router for Android and iOS
Stars: ✭ 328 (-12.77%)
Mutual labels:  transition
Easystats
🌌 The R easystats-project
Stars: ✭ 374 (-0.53%)
Mutual labels:  rstats
Pdftools
Text Extraction, Rendering and Converting of PDF Documents
Stars: ✭ 349 (-7.18%)
Mutual labels:  rstats
Dataexplorer
Automate Data Exploration and Treatment
Stars: ✭ 362 (-3.72%)
Mutual labels:  rstats
Report
📜 🎉 Automated reporting of objects in R
Stars: ✭ 348 (-7.45%)
Mutual labels:  rstats
Pyplot.jl
Plotting for Julia based on matplotlib.pyplot
Stars: ✭ 347 (-7.71%)
Mutual labels:  plotting
Animatplot
A python package for animating plots build on matplotlib.
Stars: ✭ 359 (-4.52%)
Mutual labels:  plotting
Xaringanthemer
😎 Give your xaringan slides some style
Stars: ✭ 337 (-10.37%)
Mutual labels:  rstats
Hyawesometransition
Custom transition between viewcontrollers
Stars: ✭ 368 (-2.13%)
Mutual labels:  transition
Corner.py
Make some beautiful corner plots
Stars: ✭ 327 (-13.03%)
Mutual labels:  plotting
Glot
Glot is a plotting library for Golang built on top of gnuplot.
Stars: ✭ 349 (-7.18%)
Mutual labels:  plotting
Tweetbotornot
🤖 R package for detecting Twitter bots via machine learning
Stars: ✭ 355 (-5.59%)
Mutual labels:  rstats
Lazytransitions
Lazy pop and dismiss like in the Facebook, Instagram or Twitter apps.
Stars: ✭ 377 (+0.27%)
Mutual labels:  transition

tweenr

Travis-CI Build Status AppVeyor Build Status CRAN_Release_Badge CRAN_Download_Badge Coverage Status

What is this?

tweenr is a package for interpolating data, mainly for animations. It provides a range of functions that take data of different forms and calculate intermediary values. It supports all atomic vector types along with factor, Date, POSIXct, characters representing colours, and list. tweenr is used extensibly by gganimate to create smooth animations, but can also be used by itself to prepare data for animation in another framework.

How do I get it?

tweenr is available on CRAN and can be installed with install.packages('tweenr'). In order to get the development version you can install it from github with devtools

#install.packages('devtools')
devtools::install_github('thomasp85/tweenr')

An example

Following is an example of using the pipeable tween_state() function with our beloved iris data:

library(tweenr)
library(ggplot2)

# Prepare the data with some extra columns
iris$col <- c('firebrick', 'forestgreen', 'steelblue')[as.integer(iris$Species)]
iris$size <- 4
iris$alpha <- 1
iris <- split(iris, iris$Species)

# Here comes tweenr
iris_tween <- iris$setosa %>% 
  tween_state(iris$versicolor, ease = 'cubic-in-out', nframes = 30) %>% 
  keep_state(10) %>% 
  tween_state(iris$virginica, ease = 'elastic-out', nframes = 30) %>% 
  keep_state(10) %>% 
  tween_state(iris$setosa, ease = 'quadratic-in', nframes = 30) %>% 
  keep_state(10)

# Animate it to show the effect
p_base <- ggplot() + 
  geom_point(aes(x = Petal.Length, y = Petal.Width, alpha = alpha, colour = col, 
                 size = size)) + 
  scale_colour_identity() +
  scale_alpha_identity() + 
  scale_size_identity() + 
  coord_cartesian(xlim = range(iris_tween$Petal.Length), 
                  ylim = range(iris_tween$Petal.Width))
iris_tween <- split(iris_tween, iris_tween$.frame)
for (d in iris_tween) {
  p <- p_base %+% d
  plot(p)
}

Other functions

Besides the tween_state()/keep_state() combo showcased above, there are a slew of other functions meant for data in different formats

tween_components takes a single data.frame, a vector of ids identifying recurrent elements, and a vector of timepoints for each row and interpolate each element between its specified time points.

tween_events takes a single data.frame where each row encodes a single unique event, along with a start, and end time and expands the data across a given number of frames.

tween_along takes a single data.frame along with an id and timepoint vector and calculate evenly spaced intermediary values with the possibility of keeping old values at each frame.

tween_at takes two data.frames or vectors along with a numeric vector giving the interpolation point between the two data.frames to calculate.

tween_fill fills missing values in a vector or data.frame by interpolating between previous and next non-missing elements

Easing

In order to get smooth transitions you'd often want a non-linear interpolation. This can be achieved by using an easing function to translate the equidistant interpolation points into new ones. tweenr has support for a wide range of different easing functions, all of which can be previewed using display_ease() as here where the popular cubic-in-out is shown:

tweenr::display_ease('cubic-in-out')

Spatial interpolations

The purpose of tweenr is to interpolate values independently. If paths and polygons needs to be transitioned the transformr package should be used as it expands tweenr into the spatial realm

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].