-
-
Notifications
You must be signed in to change notification settings - Fork 84
Add ColorBrewer palettes #190
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #190 +/- ##
==========================================
- Coverage 99.36% 99.31% -0.05%
==========================================
Files 30 30
Lines 4083 4088 +5
==========================================
+ Hits 4057 4060 +3
- Misses 26 28 +2
Continue to review full report at Codecov.
|
[ci skip]
@@ -310,34 +357,8 @@ is_hex_color <- function(x) { | |||
isTRUE(nchar(x) == 7) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ggplot2 will take nine character ones where the last two set the alpha level. Some palettes emit colors with these extra characters.
scales::viridis_pal()(4)
#> [1] "#440154FF" "#31688EFF" "#35B779FF" "#FDE725FF"
Not sure we need to accommodate this though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't know that. I'm not sure we need to accommodate it either, although I'm not opposed. I suppose adding support for that can be a separate issue if we every want to do it or get a request.
- use `is.null()` and `NULL` default instead of `missing()` to make interactive testing easier - refactor full_level_name to use a look-up table and get vectorization for free
Take a look at my changes and feel free to merge. |
Closes #177
This PR allows ColorBrewer palettes to be used with
bayesplot::color_scheme_set()
.Basically, if a user specifies
color_scheme_set("brewer-X")
, whereX
is the name of a ColorBrewer palette recognized by RColorBrewer, then bayesplot will useRColorBrewer::brewer.pal(n = 6, name="X")
to get the colors.I also cleaned up and rearranged some internals in the
bayesplot-colors.R
file and changed the roxygen to use markdown, so it may seem like more changed than actually did. The only change that changes any behavior is in these lines in the internalscheme_from_string()
function:bayesplot/R/bayesplot-colors.R
Lines 251 to 258 in ac6f8ae
Example Usage