sina plot - #734
Merged
Merged
sina plot#734
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved sina/violin edge-case issues and missing regression coverage remain before approval.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds a density-based sina plot type as a beeswarm alternative, with shared violin preparation and supporting documentation.
Changes:
- Implements deterministic/random sina point spreading and singleton handling.
- Refactors shared violin/sina density preparation.
- Propagates bandwidth adjustment support.
- Adds registration, tests, snapshots, documentation, and navigation updates.
File summaries
| File | Reviewed change |
|---|---|
vignettes/types.qmd |
Adds sina to the type guide. |
R/zzz.R |
Registers plotting globals. |
R/type_violin.R |
Refactors shared distribution preparation. |
R/type_sina.R |
Implements sina plotting and spread methods. |
R/type_ridge.R |
Passes bandwidth adjustment to density estimation. |
R/type_density.R |
Passes bandwidth adjustment to density estimation. |
R/sanitize_type.R |
Registers the sina type. |
NEWS.md |
Announces the new plot type. |
NAMESPACE |
Updates exports and imports. |
man/type_violin.Rd |
Documents violin and sina behavior. |
inst/tinytest/test-type_sina.R |
Adds sina tests and snapshots. |
inst/tinytest/_tinysnapshot/sina_singletons_keep.svg |
Singleton snapshot. |
inst/tinytest/_tinysnapshot/sina_on_violin.svg |
Layering snapshot. |
inst/tinytest/_tinysnapshot/sina_groups.svg |
Grouped sina snapshot. |
inst/tinytest/_tinysnapshot/sina_by_continuous.svg |
Continuous-group snapshot. |
altdoc/quarto_website.yml |
Adds sina to website navigation. |
Review details
Files not reviewed (1)
- man/type_violin.Rd: Generated file
Suppressed comments (5)
R/type_density.R:214
- This now passes the user-supplied
adjustvalue through todensity(), but the density tests only exercise the defaultadjust = 1, so they would pass even if this regression were reintroduced. Add a focused non-defaultadjusttest or snapshot that distinguishes the bandwidth from the default.
density(dat$x, bw = dens_bw, adjust = adjust, kernel = kernel, n = n, weights = wts)
R/type_ridge.R:362
- This fixes
type_ridge()to honor non-defaultadjust, but the ridge tests do not exercise that argument, so the old behavior would remain undetected. Add a focused non-defaultadjusttest or snapshot before relying on this fix.
dens = density(dat$x, bw = dens_bw, adjust = adjust, kernel = kernel, n = n)
R/type_sina.R:125
- If every cell is a singleton and the user selects the documented
"warn"or"drop"policy,cellsis empty anddo.call(rbind, datapoints)returnsNULL. The later limit calculation then takes ranges from empty vectors and errors instead of producing a plot with the singleton observations removed. Handle the zero-cell result with a valid empty data frame and consistent axis/facet/group state.
datapoints = do.call(rbind, datapoints)
R/type_violin.R:364
- The singleton check only looks at row count, so a cell with two or more identical y values still reaches the data-driven bandwidth calculation and
density(). With the defaultbw = "nrd0", base R cannot estimate a bandwidth for an essentially constant sample, so valid repeated observations can make the sina plot error instead of drawing them. Handle zero-variance cells like singleton cells or provide a safe fallback bandwidth.
bws = sapply(smoothable, function(dat) bw_fun(kernel = bw, dat[["y"]]))
R/type_violin.R:193
- This changes violin geometry for non-default
adjust, but the violin tests only use the default value, so they cannot distinguish this implementation from the pre-change code. Add a focused non-defaultadjusttest or snapshot to protect the documented argument.
dens = density(dat$y, bw = dens_bw, adjust = adjust, kernel = kernel, n = n, from = yrng[1], to = yrng[2])
- Files reviewed: 11/16 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #359
(At least, I feel that this is a fair substitute for the original beeswarm request.)
MWE
Created on 2026-09-15 with reprex v2.1.1