Skip to content

[jaspDescriptives] Add option to display bar plots as proportions/percentages (0-100...#474

Open
sisyphus-jasp wants to merge 1 commit intojasp-stats:masterfrom
sisyphus-jasp:fix-sisyphus-1773025223
Open

[jaspDescriptives] Add option to display bar plots as proportions/percentages (0-100...#474
sisyphus-jasp wants to merge 1 commit intojasp-stats:masterfrom
sisyphus-jasp:fix-sisyphus-1773025223

Conversation

@sisyphus-jasp
Copy link

Summary

Fixes: jasp-stats/jasp-issues#3953

Root cause

  • Descriptives categorical frequency plots (prop/condProp) only plotted proportions on a 0-1 scale and had no option to show 0-100 percentages with labels above bars.

What changed

  • Added new UI option densityPlotPercentWithLabels in inst/qml/Descriptives.qml (enabled only for prop/condProp).
  • Added matching backend option/default in R/descriptivesWrapper.R.
  • Updated categorical plotting path in R/descriptives.R to:
    • convert bar heights to percent when option is on,
    • add text labels above bars,
    • enforce y-axis 0-100 scale in that mode,
    • keep existing behavior unchanged when option is off.
  • Added dependency key so plot re-renders when the new option changes.

Why

  • Implements requested display mode for proportions/percentages and bar value labels while preserving existing defaults.

Caveats / reviewer checks

  • Label formatting currently uses integer-style percent text ("%3.0f%%"); review if decimal precision is desired.
  • No test files were edited (per module policy). Verified with full testAll() and direct runAnalysis() reproduction scenarios including prop and condProp.
Implementation Plan

Root cause

Descriptives categorical frequency bars are built in R/descriptives.R (.descriptivesDensityPlotsFill). For densityPlotCategoricalType = "prop" / "condProp", Freq is plotted as raw proportions (0-1), and bars have no value labels. There is no GUI option to switch these categorical bars to 0-100 percentage display with labels.

Proposed changes

  1. Add one new Frequency Plots checkbox in inst/qml/Descriptives.qml:
  • name: "densityPlotPercentWithLabels"
  • label/info: percentage mode (0-100) + values above bars
  • enabled only when categorical type is prop or condProp
  1. Add matching backend option in R/descriptivesWrapper.R:
  • roxygen @param densityPlotPercentWithLabels
  • function default densityPlotPercentWithLabels = FALSE
  1. Update R/descriptives.R:
  • include densityPlotPercentWithLabels in density plot container dependencies
  • in .descriptivesDensityPlotsFill categorical branch:
    • detect when type is proportion-based and new option is enabled
    • convert Freq to percent (* 100)
    • use y-axis 0-100 (scale_y_continuous(limits = c(0, 100), ...))
    • add percent labels above bars via geom_text
    • keep count mode and default behavior unchanged when option is off

Expected test impact

Existing tests should stay stable because default is FALSE; old behavior remains default. testAll() should pass unless hidden tests explicitly enable the new option.

Add option to display bar plots as proportions/percentages (0-100 scale) with value labels above bars in Descriptives module

Test Results

Test Run Result
Baseline (pre-fix) [ FAIL 0 | WARN 4 | SKIP 2 | PASS 66 ]
Post-fix [ FAIL 0 | WARN 4 | SKIP 2 | PASS 66 ]
Upstream CI 524f520 -- CI: passing

Automated Code Review

Approved after 1 review iteration(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: (stacked) bar plot with proportions

1 participant