Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

summary colours #29

Closed
11 tasks done
SymbolixAU opened this issue Oct 20, 2018 · 1 comment
Closed
11 tasks done

summary colours #29

SymbolixAU opened this issue Oct 20, 2018 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@SymbolixAU
Copy link
Collaborator

SymbolixAU commented Oct 20, 2018

The summary values are designed for legends & keys. So it would be good if they were formatted.

TODO

  • numeric
  • category (returns the whole palette & unique values, but in order)

TODO - numeric-to-category
i.e, return the numeric summary, but format the output

  • round doubles (use arg digits)
  • logical (treated as character)
  • factor (treated as character)
  • Date
  • POSIXct
  • POSIXlt (converted to POSIXct)
  • set format = T as the default

TODO - integration

  • confirm it's easy to call the format / summary from external packages

TODO - alpha

  • summary_values to have full alpha values (FF / 255)
@SymbolixAU SymbolixAU added this to the v0.2.0 milestone Oct 20, 2018
@SymbolixAU SymbolixAU self-assigned this Oct 20, 2018
@SymbolixAU SymbolixAU changed the title with_legend summary colours Oct 20, 2018
@SymbolixAU SymbolixAU reopened this Oct 21, 2018
@SymbolixAU SymbolixAU added the enhancement New feature or request label Oct 31, 2018
SymbolixAU pushed a commit that referenced this issue Nov 1, 2018
@SymbolixAU
Copy link
Collaborator Author

SymbolixAU commented Nov 1, 2018

Examples

Numeric values

colour_values(1:50, n_summaries = 5, alpha = 1:50)
# $colours
# [1] "#44015400" "#46085C05" "#4710630A" "#48186A0F" "#481F7014" "#4825761A" "#472C7B1F" "#46327F24" "#44398229" "#433F852E"
# [11] "#40458834" "#3E4B8939" "#3B518B3E" "#39568C43" "#365C8D48" "#34618D4E" "#31668E53" "#2F6B8E58" "#2D708E5D" "#2B758E62"
# [21] "#297A8E68" "#277F8E6D" "#25848E72" "#23898E77" "#218E8D7C" "#20938C82" "#1F978B87" "#1E9C898C" "#1FA18791" "#21A68596"
# [31] "#25AB829C" "#2AB07FA1" "#30B47BA6" "#38B977AB" "#40BD72B0" "#4AC26DB6" "#54C667BB" "#5FCA61C0" "#6BCD5AC5" "#77D153CA"
# [41] "#84D44BD0" "#91D742D5" "#9FDA3ADA" "#ACDC31DF" "#BADE28E4" "#C8E020EA" "#D6E21AEF" "#E4E418F4" "#F1E51DF9" "#FDE725FE"
# 
# $summary_values
# [1]  1.00 13.25 25.50 37.75 50.00
# 
# $summary_colours
# [1] "#440154FF" "#3B528BFF" "#21908CFF" "#5DC963FF" "#FDE725FF"

character values

colour_values(letters, summary = T)
# $colours
# [1] "#440154FF" "#471063FF" "#481E70FF" "#472B7AFF" "#453882FF" "#414487FF" "#3C4F8BFF" "#375A8CFF" "#32648EFF" "#2E6E8EFF"
# [11] "#2A788EFF" "#26828EFF" "#228B8DFF" "#1F958BFF" "#1F9E88FF" "#22A884FF" "#2CB17EFF" "#3ABA76FF" "#4DC36CFF" "#62CA5FFF"
# [21] "#7AD151FF" "#93D741FF" "#AEDC30FF" "#C9E01FFF" "#E4E418FF" "#FDE725FF"
# 
# $summary_values
# [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"
# 
# $summary_colours
# [1] "#440154FF" "#471063FF" "#481E70FF" "#472B7AFF" "#453882FF" "#414487FF" "#3C4F8BFF" "#375A8CFF" "#32648EFF" "#2E6E8EFF"
# [11] "#2A788EFF" "#26828EFF" "#228B8DFF" "#1F958BFF" "#1F9E88FF" "#22A884FF" "#2CB17EFF" "#3ABA76FF" "#4DC36CFF" "#62CA5FFF"
# [21] "#7AD151FF" "#93D741FF" "#AEDC30FF" "#C9E01FFF" "#E4E418FF" "#FDE725FF"

rounding digits

colour_values(rnorm(n = 100), n_summaries = 7, format = T, digits = 1)
# $colours
# [1] "#482273FF" "#63CB5FFF" "#38588CFF" "#6ACD5BFF" "#355D8DFF" "#443982FF" "#2A768EFF" "#2A778EFF" "#440154FF" "#29AF7FFF"
# [11] "#472E7CFF" "#24888EFF" "#21908CFF" "#287D8EFF" "#2E6E8EFF" "#27808EFF" "#46327EFF" "#414487FF" "#472E7CFF" "#5DC962FF"
# [21] "#53C568FF" "#25848EFF" "#482676FF" "#2B758EFF" "#55C667FF" "#37598CFF" "#1FA187FF" "#453882FF" "#1E9B8AFF" "#443A83FF"
# [31] "#482676FF" "#443A83FF" "#424086FF" "#433D84FF" "#1F9E89FF" "#29798EFF" "#33638DFF" "#46307EFF" "#453581FF" "#404788FF"
# [41] "#472E7CFF" "#365B8DFF" "#218F8DFF" "#482979FF" "#50C46AFF" "#482071FF" "#2D708EFF" "#D2E21BFF" "#21A685FF" "#31678EFF"
# [51] "#424086FF" "#1F958BFF" "#2B748EFF" "#34608DFF" "#24878EFF" "#38598CFF" "#FDE725FF" "#6ACD5AFF" "#1FA088FF" "#1E9C89FF"
# [61] "#39558CFF" "#21A685FF" "#34618DFF" "#453681FF" "#87D549FF" "#443C84FF" "#32648EFF" "#3B518BFF" "#443A83FF" "#1F968BFF"
# [71] "#470F61FF" "#30698EFF" "#3A538BFF" "#481A6CFF" "#2D718EFF" "#365C8DFF" "#3B528BFF" "#25AB82FF" "#20928CFF" "#2D708EFF"
# [81] "#277E8EFF" "#3F4989FF" "#306A8EFF" "#2CB27EFF" "#2B748EFF" "#277E8EFF" "#9CD93BFF" "#3E4B89FF" "#24AA83FF" "#7AD151FF"
# [91] "#46327FFF" "#2B768EFF" "#355F8DFF" "#38588CFF" "#46337FFF" "#433E85FF" "#3ABA76FF" "#1F968BFF" "#1FA088FF" "#5AC864FF"
# 
# $summary_values
# [1] "-1.7" "-1.0" "-0.2" "0.5"  "1.2"  "1.9"  "2.7" 
# 
# $summary_colours
# [1] "#440154FF" "#443A83FF" "#31688EFF" "#21908CFF" "#35B779FF" "#8FD744FF" "#FDE725FF"

Dates without format

dte <- seq(as.Date("2018-01-01"), as.Date("2018-02-01"), by = 5)
colour_values( dte , n_summaries = 3, format = F)
# $colours
# [1] "#440154FF" "#443A83FF" "#31688EFF" "#21908CFF" "#35B779FF" "#8FD744FF" "#FDE725FF"
# 
# $summary_values
# [1] 17532 17547 17562
# 
# $summary_colours
# [1] "#440154FF" "#21908CFF" "#FDE725FF"

Dates with format

dte <- seq(as.Date("2018-01-01"), as.Date("2018-02-01"), by = 5)
colour_values( dte , n_summaries = 3, format = T)
# $colours
# [1] "#440154FF" "#443A83FF" "#31688EFF" "#21908CFF" "#35B779FF" "#8FD744FF" "#FDE725FF"
# 
# $summary_values
# [1] "2018-01-01" "2018-01-16" "2018-01-31"
# 
# $summary_colours
# [1] "#440154FF" "#21908CFF" "#FDE725

POSIXct without format

psx <- seq(as.POSIXct("2018-01-01 00:00:00", tz = "Australia/Melbourne"),
           as.POSIXct("2018-02-01 00:00:00", tz = "Australia/Melbourne"),
           by = 60 * 60 * 24)
colour_values( psx, n_summaries = 5, format = F)
# $colours
# [1] "#440154FF" "#470D60FF" "#48196BFF" "#482474FF" "#472E7CFF" "#453882FF" "#414286FF" "#3E4B8AFF" "#3A548CFF" "#365D8DFF"
# [11] "#32658EFF" "#2E6D8EFF" "#2B758EFF" "#287D8EFF" "#25858EFF" "#228C8DFF" "#20948CFF" "#1E9C89FF" "#20A386FF" "#25AB82FF"
# [21] "#2DB27DFF" "#39BA76FF" "#48C16EFF" "#58C765FF" "#6ACD5BFF" "#7ED34FFF" "#92D742FF" "#A8DB34FF" "#BEDF26FF" "#D4E21BFF"
# [31] "#E9E41AFF" "#FDE725FF"
# 
# $summary_values
# [1] 1514725200 1515394800 1516064400 1516734000 1517403600
# 
# $summary_colours
# [1] "#440154FF" "#3B528BFF" "#21908CFF" "#5DC963FF" "#FDE725FF"

POSIXct with format

colour_values( psx, n_summaries = 5, format = T)
# $colours
# [1] "#440154FF" "#470D60FF" "#48196BFF" "#482474FF" "#472E7CFF" "#453882FF" "#414286FF" "#3E4B8AFF" "#3A548CFF" "#365D8DFF"
# [11] "#32658EFF" "#2E6D8EFF" "#2B758EFF" "#287D8EFF" "#25858EFF" "#228C8DFF" "#20948CFF" "#1E9C89FF" "#20A386FF" "#25AB82FF"
# [21] "#2DB27DFF" "#39BA76FF" "#48C16EFF" "#58C765FF" "#6ACD5BFF" "#7ED34FFF" "#92D742FF" "#A8DB34FF" "#BEDF26FF" "#D4E21BFF"
# [31] "#E9E41AFF" "#FDE725FF"
# 
# $summary_values
# [1] "2017-12-31T13:00:00" "2018-01-08T07:00:00" "2018-01-16T01:00:00" "2018-01-23T19:00:00" "2018-01-31T13:00:00"
# 
# $summary_colours
# [1] "#440154FF" "#3B528BFF" "#21908CFF" "#5DC963FF" "#FDE725FF"

@SymbolixAU SymbolixAU removed their assignment Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

0 participants