Skip to content

Commit

Permalink
Cleaned the theme_bw() from README and set default ggplot theme w…
Browse files Browse the repository at this point in the history
…ith `ggdist::ggdist()`
  • Loading branch information
mladenjovanovic committed Feb 4, 2024
1 parent adaadae commit 59e338a
Show file tree
Hide file tree
Showing 17 changed files with 264 additions and 230 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* For `model_in_situ()` function, the filtering parameters (`velocity_threshold`, `velocity_step`, and `n_observations`) are returned in the `corrections` element of the returned object. These are also returned in the `CV` element of the returned object for every cross-validation fold
* `velocity_threshold` parameter in the `model_in_situ()` function is now by default `NULL`, in which case the velocity of the observation with the fastest acceleration is taken as the cutoff value
* Updated the *in-situ* examples in the README file
* Cleaned the `theme_bw()` from README and set default `ggplot` theme with `ggdist::ggdist()`

# shorts 3.1.0

Expand Down
38 changes: 21 additions & 17 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ knitr::opts_chunk$set(
# To avoid re-generating figures with random noise
set.seed(1667)
# Set print options
options(
digits = 3,
"width" = 65,
scipen = 999,
knitr.kable.NA = ""
)
# Set default ggplot theme
ggplot2::theme_set(ggdist::theme_ggdist())
ggplot2::theme_update(
legend.position = "none",
strip.background = ggplot2::element_rect(fill = "grey20"),
strip.text = ggplot2::element_text(color = "white")
)
```

# shorts <img src="man/figures/logo.png" align="right" width="200"/>
Expand Down Expand Up @@ -91,23 +107,19 @@ predict(kimberley_profile)
To create a simple plot use S3 `plot()` method. There are four type options: `"model"` (default), `"kinematics-time"`, `"kinematics-distance"`, or `"residuals"`:

```{r}
plot(kimberley_profile) +
theme_bw()
plot(kimberley_profile)
```

```{r}
plot(kimberley_profile, "kinematics-time") +
theme_bw()
plot(kimberley_profile, "kinematics-time")
```

```{r}
plot(kimberley_profile, "kinematics-distance") +
theme_bw()
plot(kimberley_profile, "kinematics-distance")
```

```{r}
plot(kimberley_profile, "residuals") +
theme_bw()
plot(kimberley_profile, "residuals")
```

If you are interested in calculating average split velocity, use `shorts::format_splits()`
Expand Down Expand Up @@ -174,7 +186,6 @@ kimberley_pred <- tibble(
kimberley_pred <- gather(kimberley_pred, "metric", "value", -distance)
ggplot(kimberley_pred, aes(x = distance, y = value)) +
theme_bw() +
geom_line() +
facet_wrap(~metric, scales = "free_y") +
xlab("Distance (m)") +
Expand Down Expand Up @@ -252,8 +263,7 @@ summary(jim_profile)
confint(jim_profile)
plot(jim_profile) +
theme_bw()
plot(jim_profile)
```

In addition to $MSS$ and $MAC$ parameters, `shorts::model_radar_gun()` function also estimated *time-correction* ($TC$) parameter.
Expand Down Expand Up @@ -323,7 +333,6 @@ data("LPS_session")
LPS_session %>%
ggplot(aes(x = x, y = y)) +
theme_bw() +
geom_point(alpha = 0.1)
```

Expand All @@ -332,7 +341,6 @@ The next figure plots instant acceleration and velocity:
```{r}
LPS_session %>%
ggplot(aes(x = velocity, y = acceleration)) +
theme_bw() +
geom_point(alpha = 0.1)
```

Expand All @@ -347,7 +355,6 @@ embedded_model <- model_in_situ(
LPS_session %>%
filter(acceleration > 0) %>%
ggplot(aes(x = velocity, y = acceleration)) +
theme_bw() +
geom_point(alpha = 0.1) +
geom_point(
data = embedded_model$data,
Expand Down Expand Up @@ -416,7 +423,6 @@ loads_df <- rbind(
loads_df %>%
pivot_longer(cols = c(MSS, MAC), names_to = "parameter") %>%
ggplot(aes(x = magnitude, y = value, color = parameter)) +
theme_bw() +
geom_vline(xintercept = 0, linetype = "dotted") +
geom_line() +
facet_wrap(~type, scales = "free_x") +
Expand All @@ -438,7 +444,6 @@ dist_df <- expand_grid(
dist_df %>%
ggplot(aes(x = magnitude, y = time, color = distance)) +
theme_bw() +
geom_vline(xintercept = 0, linetype = "dotted") +
geom_line() +
facet_wrap(~type, scales = "free_x") +
Expand Down Expand Up @@ -639,7 +644,6 @@ opt_dist <- tibble(
pivot_longer(cols = 1:5, names_to = "profile")
ggplot(opt_df, aes(x = dist, y = value, color = profile)) +
theme_bw() +
geom_hline(yintercept = 100, linetype = "dashed", alpha = 0.6) +
geom_line() +
geom_point(data = opt_dist, aes(x = value, y = 100), size = 2) +
Expand Down
Loading

0 comments on commit 59e338a

Please sign in to comment.