# NOT RUN {
library(spinifex)
dat <- scale_sd(penguins[, 1:4])
clas <- penguins$species
bas <- basis_pca(dat)
mv <- manip_var_of(bas)
mt_path <- manual_tour(bas, manip_var = mv)
## d = 2 case
ggt <- ggtour(basis_array = mt_path, data = dat, angle = .3) +
proto_default(aes_args = list(color = clas, shape = clas),
identity_args = list(size = 1.5, alpha = .8))
# }
# NOT RUN {
animate_plotly(ggt)
# }
# NOT RUN {
## Finer control calling individual proto_* functions
ggt <- ggtour(basis_array = mt_path, data = dat, angle = .3) +
proto_point(aes_args = list(color = clas, shape = clas),
identity_args = list(size = 1.5, alpha = .8),
row_index = which(clas == levels(clas)[1])) +
proto_basis(position = "right",
manip_col = "red",
text_size = 7L) +
proto_origin()
# }
# NOT RUN {
animate_plotly(ggt)
# }
# NOT RUN {
## d = 1 case
bas1d <- basis_pca(dat, d = 1)
mt_path1d <- manual_tour(basis = bas1d, manip_var = mv)
ggt1d <- ggtour(basis_array = mt_path1d, data = dat, angle = .3) +
proto_default1d(aes_args = list(fill= clas, color = clas))
# }
# NOT RUN {
animate_plotly(ggt1d)
# }
# NOT RUN {
## Single basis
ggt <- ggtour(basis_array = bas, data = dat) +
proto_default(aes_args = list(fill= clas, color = clas))
## ggtour() returns a static ggplot2 plot
# }
# NOT RUN {
ggt
### or as html widget with tooltips
animate_plotly(ggt)
# }
Run the code above in your browser using DataLab