-
Notifications
You must be signed in to change notification settings - Fork 1
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
Prevent palette interpolation for some cases #149
Comments
Hmm, curious. I didn't write the code for that, but I think it's safe to say this is not the intended behavior. I don't recall running into this issue when making example plots, so I wonder if something changed in the underlying |
I've been doing some more digging this morning, and I'm noticing that this behavior doesn't occur in every case where the number of colors is smaller than the palette length. At first I noticed that it's a more common occurrence when the number of colors called is even/odd and the palette length is odd/even; but calling 4 colors on a palette of length 7 works as intended. I'm posting the example below for reference.
And from there, the palette function is simply calling
This would address this issue, but would require a significant reworking of |
Generating a discrete color palette using
cmap_*_discrete
will interpolate colors from outside of a defined palette in cases where the number of colors used is less than the number of colors in the full palette. I think this is due to the use ofgrDevices::colorRampPalette
as the palette function incolors_discrete.R
. This interpolation is useful in cases where the number of colors needed is larger than the size of the palette or for continuous scales, but for cases where the number of colors needed is less we should expect that the palette function will simply pull from the palette in order, and not interpolate usinggrDevices::colorRampPalette
. Below are the results of callingviz_palette
on the "friday" palette for different values ofnum
.I'm unsure if this is intended behavior or not. @nmpeterson do you have any insight?
The text was updated successfully, but these errors were encountered: