-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Better support for custom color and fill aesthetics? #2345
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
Comments
Some more thoughts on this: I now think all scales should have an optional aesthetics parameter, not just color scales. The same issue exists, e.g., with I think it's important to realize that the words "color", "shape", "size" etc. actually serve two distinct purposes in the scale names: First, they define what type of a scale we're dealing with (a color scale, or a shape scale, etc). Second, they name the specific aesthetic for which the scale works. Those two purposes are currently tightly coupled in ggplot2, but they don't have to be. For example, it would be perfectly reasonable to always implement color scales first as scale_fill_hue <- function(...) scale_color_hue(..., aesthetics = "fill") |
After having worked with this for about a day now, I have found one other issue: The default guide function for continuous color scales, |
I'm closing this because main primary issues have been addressed with #2555. I'll open a new issue to collect thoughts for future directions. |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
Hello,
I'm wondering whether it would be possible to better support custom color and fill aesthetics. What I mean are cases where maybe we want two separate color mappings in the same geom, e.g.
line_color
andpoint_color
. With the current ggplot2, if I create such aesthetics, I can't take advantage of any of the existing color scales. But with a few small changes, I think this would be possible.First, to demonstrate that this is a real situation, some example code from ggridges:
In this example, everything needs to be drawn at once in one geom, because the filled areas and solid lines can overlap the points. But, I want to be able to specify line colors and point colors separately, and the point colors should also be different from the fill colors. The only way I see to solve the problem is to add a
point_color
aesthetic.My code example brings up one immediate and easy to fix issue: ggplot2 doesn't export
manual_scale
, but it's what is needed here to make this example work without too much effort. Second, it would be helpful if the various existing color scales took an optionalaesthetics
argument that can be used to override the aesthetics in the function name. While this may sound a bit strange, the resulting code would be quite legible and look reasonable. For example, using the default hue color scale for fill and also applying it to the points might look like this:So, in summary, I'm making the following requests:
manual_scale
aesthetics
parameter to all existing color scalesI'd be happy to work on a pull request if you're willing to consider these changes.
The text was updated successfully, but these errors were encountered: