Skip to content

Commit b35cf63

Browse files
authored
Explain how to fix fill guide for points with filled shapes (#6229)
* Explain how to fix fill guide for points with filled shapes * Refine filled point example in docs
1 parent ebecea5 commit b35cf63

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

R/geom-point.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@
8585
#' ggplot(mtcars, aes(wt, mpg)) +
8686
#' geom_point(shape = 21, colour = "black", fill = "white", size = 5, stroke = 5)
8787
#'
88+
#' # The default shape in legends is not filled, but you can override the shape
89+
#' # in the guide to reflect the fill in the legend
90+
#' ggplot(mtcars, aes(wt, mpg, fill = factor(carb), shape = factor(cyl))) +
91+
#' geom_point(size = 5, stroke = 1) +
92+
#' scale_shape_manual(values = 21:25) +
93+
#' scale_fill_ordinal(guide = guide_legend(override.aes = list(shape = 21)))
94+
#'
8895
#' \donttest{
8996
#' # You can create interesting shapes by layering multiple points of
9097
#' # different sizes

man/geom_point.Rd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/ggplot2-specs.Rmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ ggplot(sizes, aes(size, stroke, size = size, stroke = stroke)) +
251251
scale_size_identity()
252252
```
253253

254+
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).
255+
254256
## Text
255257

256258
### Font family

0 commit comments

Comments
 (0)