Skip to content

Explain how to fix fill guide for points with filled shapes #6229

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

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions R/geom-point.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@
#' ggplot(mtcars, aes(wt, mpg)) +
#' geom_point(shape = 21, colour = "black", fill = "white", size = 5, stroke = 5)
#'
#' # The default shape used in legends is not filled, so you will need to
#' # override it in the guide in order to see the fill reflected in the legend
#' ggplot(mtcars, aes(wt, mpg, fill = factor(carb), shape = factor(cyl), colour = factor(vs))) +
#' geom_point(size = 5, stroke = 1) +
#' scale_shape_manual(values = 21:25) +
#' scale_fill_ordinal(guide = guide_legend(override.aes = list(shape = 21)))
#'
#' \donttest{
#' # You can create interesting shapes by layering multiple points of
#' # different sizes
Expand Down
7 changes: 7 additions & 0 deletions man/geom_point.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vignettes/ggplot2-specs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ ggplot(sizes, aes(size, stroke, size = size, stroke = stroke)) +
scale_size_identity()
```

Because most shapes are not filled, mapping the `fill` aesthetic of points is considered an advanced feature. Additional steps may be required to produce sensible results, such as overriding the shape used in the `fill` guide (refer to `geom_point()` for an example of this).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the first sentence clarifies anything.
I think it'd be better to just name the most common situation wherein the shape needs to be overriden, namely when you use a shape mapping with a discrete fill.

## Text

### Font family
Expand Down
Loading