Hex Sticker

How to create a hex sticker for a new package

Julian During
2021-05-23

In this post, I want to describe how I created a hex sticker for one of my shiny apps. The app itself lets users interactively explore their Strava data.

Because I called the app SummitR, I decided to display one of the most famous summit finishes in cycling history: Alpe d’Huez.

I am using the following packages:

The hexSticker package is used to create the final sticker.

Because I already climbed Alpe d’Huez on a previous occasion, I can get the data already prepared from a private github repository. The data in the corresponding repository is organised as a pin:

alpe_dhuez_id <- "1714646144"
athlete_id <- "26845822"

board_register_github(repo = "duju211/strava_act", branch = "master")

df_act <- pin_get(
  str_glue("act_{alpe_dhuez_id}_{athlete_id}"), board = "github")

board_disconnect("github")

In raw table form the data of the activity looks like this:

# A tibble: 5,326 x 11
   moving velocity_smooth grade_smooth distance altitude  time   lat
   <lgl>            <dbl>        <dbl>    <dbl>    <dbl> <int> <dbl>
 1 FALSE              0            8.6      0       787      0  45.1
 2 TRUE               0            8.6      2.1     787.     1  45.1
 3 TRUE               2.3          8.6      4.5     787.     2  45.1
 4 TRUE               2.3         10        7       788.     3  45.1
 5 TRUE               2.3         11.9      9.3     788.     4  45.1
 6 TRUE               2.3         12       11.6     788      5  45.1
 7 TRUE               2.4         11.9     14.1     788.     6  45.1
 8 TRUE               2.4         13.6     16.3     789.     7  45.1
 9 TRUE               2.3         12       18.7     789      8  45.1
10 TRUE               2.4         12.6     21.1     789.     9  45.1
# ... with 5,316 more rows, and 4 more variables: lng <dbl>,
#   heartrate <int>, cadence <int>, watts <int>

Create a minimalistic plot of the activity. Only take variables lat and lng into account:

gg_act <- df_act %>% 
  ggplot(aes(x = lng, y = lat)) +
  geom_path(color = "white") +
  theme_void() +
  theme(legend.position = "none")

Plot the path of the activity on a black background:

gg_act +
  theme_dark()

Save the finished hex sticker as result. Use the official Strava color as background color.

sticker(
  gg_act, package="SummitR", p_size=20, s_x=1.1, s_y=.75, s_width=1.3,
  s_height=1, h_fill = "#fc4c02", h_color = "white",
  filename="_posts/hex_sticker/hex_sticker.png")

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".