Skip to content

Commit e6e80cd

Browse files
author
Max Czapanskiy
committed
Simple 3d trajectory plot (line only - no ribbon)
1 parent 310a2a3 commit e6e80cd

File tree

6 files changed

+62
-7
lines changed

6 files changed

+62
-7
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
export(read_nc)
44
export(view_cats)
5+
export(view_cats_3d)
56
import(dplyr)
67
import(ggplot2)

R/viz.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,18 @@ make_subplot <- function(var, prh) {
5454
legend.title = element_blank())) %>%
5555
plotly::ggplotly(dynamicTicks = TRUE)
5656
}
57+
58+
#' Visualize CATS data as 3d geotrack
59+
#'
60+
#' @param prh A CATS PRH object (see \code{\link{read_nc}})
61+
#'
62+
#' @return A 3d plotly figure
63+
#' @export
64+
#'
65+
#' @examples
66+
#' view_cats_3d(mn200312_58)
67+
view_cats_3d <- function(prh) {
68+
prh$z <- -prh$z
69+
plotly::plot_ly(prh, x = ~x, y = ~y, z = ~z,
70+
type = "scatter3d", mode = "lines")
71+
}

README.Rmd

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@ devtools::install_github("FlukeAndFeather/catsr")
3434

3535
## Reading data
3636

37-
Read a CATS PRH file in NetCDF format.
37+
Read a CATS PRH file in NetCDF format. The .nc file for deployment mn200312-58 is included in the package.
3838

3939
```{r read}
4040
library(catsr)
4141
nc_path <- system.file("extdata", "mn200312-58_prh10.nc", package = "catsr")
42-
mn200312_58 <- read_nc(nc_path)
42+
mn200312_58_from_nc <- read_nc(nc_path)
4343
```
4444

45-
Examine PRH variables (e.g. depth, pitch, and roll) in an interactive plot. GitHub READMEs don't support interaction, so a screenshot is supplied instead.
45+
## Visualizing data
46+
47+
Examine PRH variables (e.g. depth, pitch, and roll) in an interactive plot. This package also provides deployment mn200312-58 directly for use in R (`mn200312_58`). GitHub READMEs don't support interaction, so we show a screenshot here instead.
4648

4749
```{r plot}
4850
view_cats(mn200312_58, c("p", "pitch", "roll"))
@@ -54,3 +56,8 @@ Triaxial variables (such as accelerometry - `aw`) are represented in multiple co
5456
view_cats(mn200312_58, c("p", "aw", "mw"))
5557
```
5658

59+
Explore the animal's 3d movement trajectory.
60+
61+
```{r plot_3d}
62+
view_cats_3d(mn200312_58)
63+
```

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,21 @@ devtools::install_github("FlukeAndFeather/catsr")
2424

2525
## Reading data
2626

27-
Read a CATS PRH file in NetCDF format.
27+
Read a CATS PRH file in NetCDF format. The .nc file for deployment
28+
mn200312-58 is included in the package.
2829

2930
``` r
3031
library(catsr)
3132
nc_path <- system.file("extdata", "mn200312-58_prh10.nc", package = "catsr")
32-
mn200312_58 <- read_nc(nc_path)
33+
mn200312_58_from_nc <- read_nc(nc_path)
3334
```
3435

36+
## Visualizing data
37+
3538
Examine PRH variables (e.g. depth, pitch, and roll) in an interactive
36-
plot. GitHub READMEs don’t support interaction, so a screenshot is
37-
supplied instead.
39+
plot. This package also provides deployment mn200312-58 directly for use
40+
in R (`mn200312_58`). GitHub READMEs don’t support interaction, so we
41+
show a screenshot here instead.
3842

3943
``` r
4044
view_cats(mn200312_58, c("p", "pitch", "roll"))
@@ -50,3 +54,11 @@ view_cats(mn200312_58, c("p", "aw", "mw"))
5054
```
5155

5256
<img src="man/figures/README-plot_triax-1.png" width="100%" />
57+
58+
Explore the animal’s 3d movement trajectory.
59+
60+
``` r
61+
view_cats_3d(mn200312_58)
62+
```
63+
64+
<img src="man/figures/README-plot_3d-1.png" width="100%" />

man/figures/README-plot_3d-1.png

20.1 KB
Loading

man/view_cats_3d.Rd

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)