CMAP-REPOS / cmapplot

Set of templates and themes to apply CMAP graphics standards to R products.
https://cmap-repos.github.io/cmapplot/
Other
13 stars 1 forks source link

unable to use cmapplot continuous color palettes for fill aesthetic #119

Closed tkoyejo closed 3 years ago

tkoyejo commented 3 years ago

I wanted to apply the built-in CMAP continuous palette to produce a continuous gradient fill aesthetic in a stacked bar chart. When I apply cmap_fill_continuous(palette = "seq_blues") to a stacked bar chart, I get the following error: "Error: Discrete value supplied to continuous scale". If I switch to cmap_color_continuous(palette = "seq_red_purple"), the code is ignored and the default ggplot colors are used.

I ended up having to use the ggplot color brewer, which worked. The example output I seek is attached. scale_fill_brewer(palette = "Blues")

figure17_title

matthewstern commented 3 years ago

@gritzenthaler, this is a bit of a different color application than we had originally scoped and tested. Is this code modifiable to enable the application of a continuous palette to a discrete set of categories?

gritzenthaler commented 3 years ago

Yes I believe we talked about this sort of application a while ago, particularly in regards to choropleth maps. I'm sure it's possible, so I'll look into it once I have some time in the coming week.

matthewstern commented 3 years ago

Is this the same issue as #70?

tkoyejo commented 3 years ago

If I'm reading this right, sounds like the same issue to me.

matthewstern commented 3 years ago

@gritzenthaler for the time being I've assigned you to both issues and added both to the v1.2 milestone. Feel free to close one or the other if you determine them to be duplicates.

dlcomeaux commented 3 years ago

@gritzenthaler @matthewstern I was trying to add a discrete argument to the cmap_*_continuous family, and then I realized - is there any reason that we couldn't just combine the two palette lists (or rather, the cmap_palettes and cmap_gradients) lists? I did a test with that, and it was able to use the sequences and the diverging sequences in the manner we want. We'd probably want some additional code to flag when a palette is being used inappropriately (and perhaps we should only allow for the gradients to be used as palettes and not vice versa), but I think that would achieve what we want with only minimal change required.

I'll start prepping what it would look like.