Skip to content

Conversation

@SchmidtPaul
Copy link
Contributor

Summary

This PR fixes ggdesplot() to properly respect user-provided out1.gpar and out2.gpar parameters for customizing outline appearance. Previously, outline colors, line widths, and line types were hardcoded, completely ignoring these documented parameters.

Changes

  • Extract col, lwd, and lty from out1.gpar and out2.gpar lists
  • Apply these parameters to geom_tileborder() calls (lines 465-480 in R/ggdesplot.R)
  • Fixed a bug where hardcoded values didn't match documented defaults (e.g., out1 default lwd=3 was being rendered as lwd=1.5)

Testing

Tested with agridat::besag.met dataset. All examples work as expected:

library(desplot)
library(agridat)

# Test 1: Default colors (black and yellow)
ggdesplot(besag.met, yield ~ col*row|county, 
          out1=rep, out2=block,
          main="Default: black out1, yellow out2")

# Test 2: Custom colors with different line widths
ggdesplot(besag.met, yield ~ col*row|county, 
          out1=rep, out2=block,
          out1.gpar=list(col="red", lwd=3),
          out2.gpar=list(col="blue", lwd=2),
          main="Custom colors: thick red out1, blue out2")

# Test 3: Custom line types
ggdesplot(besag.met, yield ~ col*row|county, 
          out1=rep, out2=block,
          out1.gpar=list(col="darkgreen", lwd=2, lty="dashed"),
          out2.gpar=list(col="orange", lwd=1.5, lty="dotted"),
          main="Line types: dashed green out1, dotted orange out2")

# Test 4: Match the documented example styling
ggdesplot(besag.met, yield ~ col*row|county, 
          out1=rep, out2=block,
          out1.gpar=list(col="black", lwd=3),
          out2.gpar=list(col="gray50", lwd=1, lty=1),
          main="Styled like lattice examples")

Benefits

Users can now customize outline appearance as documented
Brings ggplot2 version closer to feature parity with lattice version
Fixes inconsistency between documented defaults and actual rendering
Enables matching the styling of lattice-based desplot examples

Previously, outline colors and line widths were hardcoded, ignoring
user-provided out1.gpar and out2.gpar parameters. This fix extracts
color, line width (lwd), and line type (lty) from the gpar lists
and applies them to the outline borders.

Additionally, this fixes a bug where the hardcoded values didn't
match the documented defaults (e.g., out1 default lwd=3 was being
rendered as lwd=1.5).

Now users can customize outline appearance as documented, for example:
  out1.gpar=list(col="red", lwd=2, lty=2)
  out2.gpar=list(col="blue", lwd=0.5, lty=1)
@kwstat
Copy link
Owner

kwstat commented Nov 13, 2025

Thanks for giving ggplot some fixes.

@kwstat kwstat merged commit 01934c5 into kwstat:main Nov 13, 2025
1 check passed
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.

3 participants