wmurphyrd / colorplaner

📊ggplot2 Extension to Visualize Two Variables Per Color Aesthetic through Color Space Projection
31 stars 4 forks source link

Changing color start stop points #3

Closed bhive01 closed 8 years ago

bhive01 commented 8 years ago

I'm trying to help someone make chloropleths on the ggplot2 mailing list: https://groups.google.com/forum/#!topic/ggplot2/CGXSILwAiOg

I asked for help on Twitter and Hadley responded with a link to your package. The resulting plot with your package is great, but the requirements laid out by OP are that one scale goes from white to red and the other from white to blue. Purple would then be made when the two intersect. I hacked together something that did what your package does (without the very nice guide), but there's no sense in reinventing the wheel on this.

I've read the docs and package introduction, but I don't see a way to change the color scale from what you've predefined. While your definition is a good one, having the ability to set it to what you want would be useful.

wmurphyrd commented 8 years ago

Giving the option to replace the YUV projection with a user specified function is in my todo list. I'll try to get a branch up with this today.

wmurphyrd commented 8 years ago

The branch other_projections now contains a working prototype with a sample white/red/blue/purple projection options and the framework to provide custom projection functions (see ?color_projections).

I don't think the new projection is very interpretable, but others could probably do a better job on the color math. Check the last example in the readme on that branch to see what it looks like or install it with:

devtools::install_github("wmurphyrd/colorplaner", ref = "other_projections")
bhive01 commented 8 years ago

I see what you mean. The "purple" does stand out, but is more of a pink to my eyes. The colors themselves are literally additive in your function. I can see how it's working well with the YUV. You're holding Y hostage at 128 and scaling the data to U and V, which is spectacular. The red/blue is more what I was thinking using RGB values, but I didn't consider very well that 255,0,255 is bright pink, not a nice dark purple color, which OP is more after.

I wonder if a similar thing could be done in your YUV graph using Hue/Chroma with a fixed lightness in HCL colorspace. I usually think about measurement of color, not so much on how to make them represent data better. A fun exercise.

wmurphyrd commented 8 years ago

Came up with a better red_blue projection by using colorRamp to interpolate from white to red or blue for each variable independently and then taking a simple average blend for each plotted color. image

Also generalized that process in the interpolate_projection function to create a color plane from any 3 given colors.