Skip to content

Commit

Permalink
Explain how to fix fill guide for points with filled shapes (#6229)
Browse files Browse the repository at this point in the history
* Explain how to fix fill guide for points with filled shapes

* Refine filled point example in docs
  • Loading branch information
arcresu authored Dec 13, 2024
1 parent ebecea5 commit b35cf63
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
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 in legends is not filled, but you can override the shape
#' # in the guide to reflect the fill in the legend
#' ggplot(mtcars, aes(wt, mpg, fill = factor(carb), shape = factor(cyl))) +
#' 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 points are not typically filled, you may need to change some default settings when using these shapes and mapping `fill`. In particular, discrete `fill` guides will be drawn with an unfilled shape unless overridden (refer to `geom_point()` for an example of this).

## Text

### Font family
Expand Down

0 comments on commit b35cf63

Please sign in to comment.