[jaspNetwork] Fix y-axis limits in Posterior Structure Probability and...#175
Open
sisyphus-jasp wants to merge 1 commit into
Open
[jaspNetwork] Fix y-axis limits in Posterior Structure Probability and...#175sisyphus-jasp wants to merge 1 commit into
sisyphus-jasp wants to merge 1 commit into
Conversation
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.
Summary
Fixes: https://github.com/jasp-stats/INTERNAL-jasp/issues/3101
Fix Summary: Y-axis limits in Posterior Structure Probability and Complexity Plot
What was wrong
The Posterior Structure Probability plot and Complexity Plot in Bayesian Network Analysis had y-axis limits that could clip data points at the edges. This happened because
geom_point()was used without explicit y-axis scaling, causing points near y=0 or at the maximum probability to be cut off.Root cause
The plots used
geom_point()combined withgeom_rangeframe()andthemeJaspRaw()without explicit y-axis limits. ggplot2's default behavior clips points at the plot boundaries.What was changed
Added
ggplot2::scale_y_continuous(expand = ggplot2::expansion(mult = c(0, 0.05)))to both plots:R/bayesiannetworkanalysis.R:498): Added 5% padding at the upper end of the y-axisR/bayesiannetworkanalysis.R:700): Added the same y-axis scalingThe fix ensures all data points are visible by adding 5% padding at the upper end while keeping the lower bound at 0.
Test results
Implementation Plan
Plan: Fix y-axis limits in Posterior Structure Probability and Complexity Plot
Root Cause
The Posterior Structure Probability plot (line 464-505) and Complexity Plot (line 658-708) in
R/bayesiannetworkanalysis.Rusegeom_point()without explicit y-axis limits. This causes data points at the edges to be clipped, particularly:The issue is that ggplot2's default behavior clips points at the plot boundaries when using
geom_rangeframe()andthemeJaspRaw().Proposed Changes
Modify both plot functions to add explicit y-axis scaling:
Posterior Structure Plot (line ~498):
ggplot2::scale_y_continuous(expand = ggplot2::expansion(mult = c(0, 0.05)))after the themeComplexity Plot (line ~699):
scale_y_continuousto ensure all data points are visibleThe fix adds 5% padding at the upper end of the y-axis while keeping the lower bound at 0, ensuring all data points are included in the plot.
Files to Modify
R/bayesiannetworkanalysis.R:.bayesianNetworkAnalysisPosteriorStructurePlot()function (around line 498).bayesianNetworkAnalysisPosteriorComplexityPlot()function (around line 699)Test Impact
The existing tests should pass as this is a visual fix that doesn't change the computed values. The tests currently do not test plots extensively (as noted in the test file comment: "# does not test ... - plots or graphical options").
Fix y-axis limits in Posterior Structure Probability and Complexity Plot to include all data points
Screenshot Analysis
screenshot-1.png:
Description of the Screenshot
This screenshot is from the JASP statistical software, specifically showing the Bayesian Network Analysis module. Below is a detailed breakdown of the UI elements, selected options, analysis settings, and visible output:
1. JASP Module and Analysis
2. Selected Options and Analysis Settings
Left Panel: Variables
V1,contBinom,contExpon,contWide,contNarrow,contOutlier,facGender,facExperim,facFive,facFifty,facOutlier,debString,debMiss1,debMiss30,debMiss80,debBinMiss20.facGenderis currently selected (highlighted in gray).Model Dropdown
gcgm (mixed).Plots Section
Inclusion Criteria
Tables Section
BF10selected as the measure).Network Structure Selection
Other Options
3. Output Elements
Right Panel: Plots
Posterior Structure Probability Plot
Complexity Plot
Dependent Variables
contNormalcontGammacontcor1contcor24. State and Observations
facGendervariable and is performing a Bayesian network analysis using thegcgm (mixed)model.BF10 > 10.5. Potential Issue
Summary of the Issue
The user appears to be conducting a Bayesian network analysis in JASP and has highlighted the Network labels in the posterior structure probability plot and complexity plot. This suggests that the issue might be related to the labeling, interpretation, or display of these plots. No explicit error message is present in the screenshot.
Final Answer:
\boxed{\text{The user is conducting a Bayesian network analysis in JASP, with selected options for plots and tables. The red boxes highlight the 'Network' labels in the posterior structure probability plot and complexity plot, indicating a potential issue with labeling or interpretation.}}
Test Results
Automated Code Review
Approved after 1 review iteration(s).