Lego Visualization

lego_plot <- base %>%
  summarise(sum = sum(n)) %>%
  add_markers(
    x= ~sum, 
    y = ~fct_reorder(name.x, sum),
    hoverinfo = "x+y"
  ) %>%
  layout(
    xaxis = list(title = "Sum of Lego Sets"),
    yaxis = list(title = "Number of Lego Sets")
  ) 

subplot(lego_plot, time_series, widths = c(.2, .8), titleX = TRUE) %>%
  layout(showlegend = FALSE) %>%
  highlight(on = "plotly_selected", dynamic = TRUE, selectize = TRUE, persistent = TRUE)
## Adding more colors to the selection color palette.
## We recommend setting `persistent` to `FALSE` (the default) because persistent selection mode can now be used by holding the shift key (while triggering the `on` event).
## Setting the `off` event (i.e., 'plotly_deselect') to match the `on` event (i.e., 'plotly_selected'). You can change this default via the `highlight()` function.

Lego Data Set

head(lego_wrangle)
## # A tibble: 6 × 3
## # Groups:   name.x [1]
##   name.x     year     n
##   <chr>     <dbl> <int>
## 1 Star Wars  1999     1
## 2 Star Wars  2000     4
## 3 Star Wars  2001     3
## 4 Star Wars  2002     7
## 5 Star Wars  2003     1
## 6 Star Wars  2009     1

From https://www.kaggle.com/rtatman/lego-database/version/1?select=themes.csv and was made merging themes.csv and sets.csv while filtering by themes containing ‘Star Wars’

References

https://plotly-r.com/index.html

Reflection

The ideas and suggestions from Claus Wilke’s helped shaped my visualization in that originally I was trying to create a visualization that would show all of the sets within Lego themes across the years. However, that quickly became cluttered and too hard to gain any meaningful information out of. Thus I went down the route of looking into only Star Wars themes and the code was built that it is easy to modify to look into any particular sets and compare.

I wish I was able to create more comparison ability with filters to compare different sets other than just Star Wars without it becoming to cluttered of a set. I also want to fix the axis and other visual aesthetics.

The most interesting part of this was the plotly highlight function trying to color lines on click and also being able to select set names within a theme in order to compare.