Open dgkf opened 4 years ago
Thanks @dgkf!
This is somewhat by design -- sequential_gradient()
also takes into account the perceptual distance between fg/accent and bg/accent and weights accordingly (in this case, there's a larger perceptual distance between bg and accent, which is why you get the bg endpoint, but not the fg).
As long as fg
/accent
/bg
are based on the same or similar hue (which they should be in order for it even to make sense to make sequential colorscale out these colors), then I don't think this is much of problem (feel free to convince me otherwise :)
Also, keep in mind that you can also provide the colors directly to sequential
, in which cases, the "usual" linear interpolation is applied:
thematic_on(sequential = c("#FF0000", "#00FF00", "#0000FF"))
qplot(1:10, 1:10, color = 1:10)
Also, if you want to do this in a way that works with auto-theming, you can provide a function:
thematic_on(sequential = function(fg, accent, bg) { scales::colour_ramp(c(fg, accent, bg))(seq(0, 1, by = 0.1)) })
Thanks @cpsievert - that sounds good. I didn't realize it was doing additional work to try to make the color presentation more consistent. Perhaps a mention of this behavior could be added to the sequential_gradient
documentation.
I should have tried out just passing values - I think that works just fine for my purposes.
Describe the problem
Thanks for the wonderful talk today at R/Pharma, @cpsievert! I've been having fun playing around with
thematic
today. In the course of tinkering with the package and trying to build some of my own themes, I found that the values produced by the generated function ofsequential_gradient
were starting after the expected starting color value.I would expect the first value to be the same as the provided
fg
color, but it seems to begin the gradient with a value already partway in transition fromfg
toaccent
.Session Info