Consistent fill lighten for area types#657
Conversation
|
To support specifications like By default this yields similar colors as the current Additionally, we may want to build in a catch that makes sure that |
|
Thanks @zeileis, I think that both (tl;dr I'm leaving for 3 weeks vacation, with limited computer access. But I have to get this next CRAN submission out first, so that some work colleagues can easily use v0.7.0 for an internal project while I'm gone. It's a long story, but they need some our latest features and also have to install from the official CRAN distribution for some infosec reasons.) Anyway, the bottom line is that I need to merge this today if it's going to make the v0.7.0 submission. IMHO it should be included if at all possible and I also feel it's basically in good enough shape now. But I can hold off until later today if you need/want to confirm anything else on your side. Let me know! |
|
P.S. I realize that I didn't include any spineplot MWEs above. I was probably unnecessarily confusing in my previous comment #646 (comment)... The takehome version is that, for most cases, spineplots are essentially unchanged. The only user-facing changes that I implemented were:
pkgload::load_all("~/Documents/Projects/tinyplot/")
#> ℹ Loading tinyplot
tinytheme("clean2")
tinyplot(
Species ~ Sepal.Length, data = iris,
type = "spineplot"
)tinyplot(
Species ~ Sepal.Length, data = iris,
type = "spineplot", lty = 0
)
tinyplot(
Species ~ Sepal.Length | Species, data = iris,
type = "spineplot"
)tinyplot(
Species ~ Sepal.Length | Species, data = iris,
type = type_spineplot(lighten = TRUE)
) |
There was a problem hiding this comment.
Pull request overview
This PR addresses #646 by making multi-group area-based plot types use consistent lighter-but-opaque fills (matching the single-group look), while introducing an explicit lighten toggle to opt out where appropriate (and keeping histogram/spineplot defaults aligned with their visual constraints).
Changes:
- Add
lightensupport tobarplot,boxplot, andviolintypes (defaultTRUE) and update fill/alpha layering so numericfill/alphaapplies on top of the (optionally lightened) base fill. - Add
lightensupport tospineplot(defaultFALSE, only meaningful for they == bycase) and adjust legend fill resolution for grouped spineplots. - Update documentation, vignettes, tests, and snapshot artifacts to reflect the new defaults and options.
Reviewed changes
Copilot reviewed 22 out of 61 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| vignettes/gallery_figs/spineplot-titanic.R | Adjusts gallery figure params to match updated spineplot/legend styling. |
| vignettes/gallery_figs/likert.R | Uses type_barplot(lighten = FALSE, ...) to preserve intended saturated fills in the likert example. |
| vignettes/gallery_figs/barplot-meat.R | Demonstrates opting out of fill lightening for barplots in gallery output. |
| R/zzz.R | Adds lighten to the recognized argument set used across the package. |
| R/type_violin.R | Introduces lighten parameter plumbed into violin type data for consistent grouped fills. |
| R/type_spineplot.R | Adds lighten option for y == by spineplots and refines frame/legend behavior. |
| R/type_boxplot.R | Introduces lighten parameter for boxplots and routes it into type data. |
| R/type_barplot.R | Introduces lighten parameter for barplots and routes it into type data. |
| R/tinyplot.R | Adds a global settings$lighten default used by grouped-fill resolution. |
| R/legend.R | Ensures grouped spineplot legends mirror plotted fill behavior (including lightening). |
| NEWS.md | Documents the grouped-fill consistency change and new lighten options. |
| man/type_violin.Rd | Updates generated docs for new violin behavior/arguments. |
| man/type_spineplot.Rd | Updates generated docs for new spineplot behavior/arguments. |
| man/type_boxplot.Rd | Updates generated docs for new boxplot behavior/arguments. |
| man/type_barplot.Rd | Updates generated docs for new barplot behavior/arguments. |
| inst/tinytest/test-type_violin.R | Updates violin snapshot tests for new defaults and adds lighten = FALSE coverage. |
| inst/tinytest/test-type_spineplot.R | Updates spineplot snapshot tests and adds lighten = TRUE coverage for y == by. |
| inst/tinytest/test-type_boxplot.R | Adds snapshot coverage for type_boxplot(lighten = FALSE). |
| inst/tinytest/test-type_barplot.R | Updates barplot snapshot tests for new defaults and adds lighten = FALSE coverage. |
| inst/tinytest/test-tinyplot_add.R | Updates jitter-layer snapshots impacted by new fill/alpha behavior. |
| inst/tinytest/_tinysnapshot/spineplot_yby.svg | Snapshot update reflecting spineplot legend/frame styling changes. |
| inst/tinytest/_tinysnapshot/spineplot_yby_lighten_true.svg | New snapshot for spineplot with lighten = TRUE in the y == by case. |
| inst/tinytest/_tinysnapshot/spineplot_yby_lighten_false.svg | New snapshot for spineplot with lighten = FALSE in the y == by case. |
| inst/tinytest/_tinysnapshot/spineplot_xby.svg | Snapshot update reflecting spineplot legend/frame styling changes. |
| inst/tinytest/_tinysnapshot/spineplot_facet_by.svg | Snapshot update reflecting spineplot legend/frame styling changes. |
| inst/tinytest/_tinysnapshot/boxplot_groups.svg | Snapshot update for new grouped boxplot fill behavior. |
| inst/tinytest/_tinysnapshot/boxplot_groups_x_same.svg | Snapshot update for new grouped boxplot fill behavior. |
| inst/tinytest/_tinysnapshot/boxplot_groups_x_same_legendFALSE.svg | Snapshot update for new grouped boxplot fill behavior without legend. |
| inst/tinytest/_tinysnapshot/boxplot_groups_x_equivalent.svg | Snapshot update for new grouped boxplot fill behavior. |
| inst/tinytest/_tinysnapshot/boxplot_groups_x_equivalent_legendFALSE.svg | Snapshot update for new grouped boxplot fill behavior without legend. |
| inst/tinytest/_tinysnapshot/boxplot_groups_lighten_false.svg | New snapshot for grouped boxplot with lighten = FALSE. |
| inst/tinytest/_tinysnapshot/boxplot_groups_facets_with_missings.svg | Snapshot update for new grouped boxplot fill behavior with facets/missings. |
| inst/tinytest/_tinysnapshot/boxplot_groups_argpass.svg | Snapshot update for grouped boxplot argument-passing case under new fill behavior. |
| inst/tinytest/_tinysnapshot/boxplot_facet_by_x_same.svg | Snapshot update for faceted grouped boxplot under new fill behavior. |
| inst/tinytest/_tinysnapshot/barplot_offset_stacked.svg | Snapshot update for barplot offset example under new fill behavior. |
| inst/tinytest/_tinysnapshot/barplot_offset_beside_group.svg | Snapshot update for barplot offset/beside grouped example under new fill behavior. |
| inst/tinytest/_tinysnapshot/barplot_group.svg | Snapshot update for grouped barplot under new default lightened fills. |
| inst/tinytest/_tinysnapshot/barplot_group_lighten_false.svg | New snapshot for grouped barplot with lighten = FALSE. |
| inst/tinytest/_tinysnapshot/barplot_group_beside.svg | Snapshot update for grouped barplot (beside) under new fill behavior. |
| inst/tinytest/_tinysnapshot/barplot_flip_fancy.svg | Snapshot update for flipped “fancy” barplot under new fill behavior. |
| inst/tinytest/_tinysnapshot/barplot_facet.svg | Snapshot update for faceted barplot under new fill behavior. |
| inst/tinytest/_tinysnapshot/barplot_facet_free.svg | Snapshot update for faceted free-scale barplot under new fill behavior. |
| inst/tinytest/_tinysnapshot/barplot_custom_ytitle.svg | Snapshot update for custom-title barplot under new fill behavior. |
| inst/tinytest/_tinysnapshot/barplot_custom_xtitle.svg | Snapshot update for custom-title barplot under new fill behavior. |
| inst/tinytest/_tinysnapshot/barplot_aggregation.svg | Snapshot update for aggregated barplot under new fill behavior. |
| altdoc/pkgdown.yml | Updates pkgdown build timestamp metadata. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.




Closes #646
Using the same summary that I shared in my earlier comment:
barplot,boxplot, andviolinnow use the same lighter-but-opaque fill as their single-group counterparts. This fixes the the original inconsistency that you pointed out at the top of this issue (dark saturated bars vs. semi-transparent boxes).lightenargument (default TRUE). So, for example, you could override withtype_barplot(lighten = FALSE)to fall back to the old saturated palette colour.spineplotalso gets a similar lightening treatment, but only for the specialy == bycase. I've also made sure that these get consistent (black) borders regardless of grouping.MWE
Using some of the examples from the original issues:
Created on 2026-07-01 with reprex v2.1.1