/test/path_curves.r

http://github.com/ggobi/tourr · R · 40 lines · 24 code · 10 blank · 6 comment · 1 complexity · 9cf1d19a2d7935f6c5e9b5274fb74475 MD5 · raw file

  1. ### Name: path_curves
  2. ### Title: Draw the path that the geodesics took.
  3. ### Aliases: path_curves
  4. ### ** Examples
  5. path1d <- save_history(flea[, 1:6], grand_tour(1), 10)
  6. path2d <- save_history(flea[, 1:6], grand_tour(2), 10)
  7. if (require("ggplot2")) {
  8. plot(path_curves(path1d))
  9. plot(path_curves(interpolate(path1d)))
  10. plot(path_curves(path2d))
  11. plot(path_curves(interpolate(path2d)))
  12. # Instead of relying on the built in plot method, you might want to
  13. # generate your own. Here are few examples of alternative displays:
  14. df <- path_curves(path2d)
  15. ggplot(data = df, aes(x = step, y = value, group = obs:var, colour = var)) +
  16. geom_line() +
  17. facet_wrap(~obs)
  18. library(tidyr)
  19. ggplot(
  20. data = pivot_wider(df,
  21. id_cols = c(obs, step),
  22. names_from = var, names_prefix = "Var",
  23. values_from = value
  24. ),
  25. aes(x = Var1, y = Var2)
  26. ) +
  27. geom_point() +
  28. facet_wrap(~step) +
  29. coord_equal()
  30. }