Fix issue 1546, fill aesthetic does not show in the legend guide for stat_summary #2567
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I think the way to fix this issue is to give
geom_smooth()
a first-classse
parameter that is considered when drawing the panel. This allows the geom and the legend drawing code to always be in synch. See resulting behavior in the examples below.One note: Currently one regression test fails because the
geom_smooth()
anddraw_group()
functions have different default arguments and the test checks for that. I think the test is wrong in this particular case, but I wanted to bring this up for discussion. Relevant lines in the code, with explanation for why it should be this way:https://github.com/clauswilke/ggplot2/blob/ed016144c97cf67424498453a2f4e06925fdba92/R/geom-smooth.r#L119-L126
Examples of
geom_smooth()
withstat_summary()
:And, for completeness, all combinations of
geom_smooth()
/stat_smooth()
withse = TRUE
/se = FALSE
work as expected:Created on 2018-05-10 by the reprex package (v0.2.0).