Skip to content

Conversation

@robe2037
Copy link

This PR revises the way color palettes are handled for path coloring. The main updates are:

  • Adds color_paths_by argument to frames_spatial(), frames_graph(), and view_spatial(). This argument accepts a variable name (either for a track attribute or event attribute) to use for coloring tracks. This replaces the need/option to manually generate a colour column in the input data prior to generating the animation frames. Instead, users can provide the variable name and the color mapping is handled internally.
  • path_colours now also accepts a palette function in addition to a vector of colors. This allows users to flexibly color tracks without needing prior knowledge about the number of levels that exist in the attribute being used for coloring.
  • These arguments support both qualitative and continuous variables. The internals are not particularly elegant, but identify the correct scale type based on the data type of the input variable and adjust the way the frame legends are constructed accordingly. In the future it could be worth having a more explicit split between these two data types. (Continuous variables aren't supported in frames_graph() because of seemingly limited utility for this use-case.)
  • Legend title now defaults to the name of the variable being used for coloring

One downside to the current approach is that the legend construction is somewhat decoupled from the coloring of the tracks (i.e. we don't use the palettes that are passed for construction of the legend directly when generating track colors). This is a consequence of the fact that track coloring requires additional detail to correctly color tails/traces, but it does make the code less internally consistent. Still, the legend construction does reliably reflect the track colors using this approach.

As a note, this branch also depends directly on the legend-lbls-fix branch, which has a separate PR. This is because it wouldn't have been possible to check whether legend behavior was correct without having already fixed the baseline legend ordering.

Makes `frames_spatial()` consistent with `frames_graph()` after fixing label mapping
This allows for color scale to dynamically adapt to levels in attribute data
Uses scales package to simplify color mapping
For consistency with `path_colours`
Have not updated anything currently listed as out-of-date
int64 common in move2 objects
Makes legend mapping more robust and reduces skew in continuous legends
Speeds up animations that color by continuous vars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant