nspyrison/spinifex

plotly printer for history arrays

Closed this issue · 4 comments

Given output from the tourr::save_history function I want to generate a plotly animation of the results, for example to play a previously recorded guided tour.

Example:
data <- flea[, 2:6]
tourHistory <- save_history(data, guided_tour(cmass))
plotlyPrint(data, tourHistory) #pass in data separately so we can play same tour for different datasets

where plotlyPrint should take data and (non-interpolated) history, then interpolate the planes with the tourr function "interpolate()", potentially passing on the "angle" parameter. Additional parameters that could be useful would be grouping for formatting (color, symbols). The function should return a plotly object that can readily be inserted e.g. in rmarkdown.

Look at spinifex::play_tour

#installation
devtools::install_github("nspyrison/spinifex")
?play_tour

flea_std <- tourr::rescale(tourr::flea[,1:6])
tpath <- tourr::save_history(flea_std, tourr::guided_tour(tourr::cmass))

play_tour(tour = tpath, data = flea_std)

play_tour(tour = tpath, cat_var = flea$species) #cat_var, 
play_tour(tour = tpath, data =  tourr::rescale(wine[,2:7])) #different data

I see what you mean with interpolate() now, will add that when I have time. cat_var currently handles grouping pch and color, will you need more control than that?

Nice!

For me the axis labels are missing, do they still need to be added?
In general I would prefer more control, but having the cat_var argument should be sufficient to handle most cases, so I would not assign high priority to that.

Axis label issue was from an issue with plotly, workaround is in place for that. Will go through and break out cat_var, in pch and col, making sure that NAs work.

available with

tpath <- tourr::save_history(flea_std, tourr::guided_tour(tourr::cmass))

play_tour_path(tour_path = tpath)

play_tour_path(tour_path = tpath, data, col, pch, lab)