From 68592d291beb95a5bcc6b47e98afb635004db60e Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Tue, 10 Dec 2024 13:46:54 +0100 Subject: [PATCH 1/3] add boosts to radius --- R/coord-polar.R | 6 +++--- R/coord-radial.R | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/coord-polar.R b/R/coord-polar.R index de9453ddb9..b8855f52b9 100644 --- a/R/coord-polar.R +++ b/R/coord-polar.R @@ -84,7 +84,7 @@ CoordPolar <- ggproto("CoordPolar", Coord, is_free = function() TRUE, - distance = function(self, x, y, details) { + distance = function(self, x, y, details, boost = 0.75) { arc <- self$start + c(0, 2 * pi) dir <- self$direction if (self$theta == "x") { @@ -94,8 +94,8 @@ CoordPolar <- ggproto("CoordPolar", Coord, r <- rescale(x, from = details$r.range) theta <- theta_rescale_no_clip(y, details$theta.range, arc, dir) } - - dist_polar(r, theta) + # The ^boost boosts detailed munching when r is small + dist_polar(r^boost, theta) }, backtransform_range = function(self, panel_params) { diff --git a/R/coord-radial.R b/R/coord-radial.R index de3bac2d00..e9251f3ab0 100644 --- a/R/coord-radial.R +++ b/R/coord-radial.R @@ -120,7 +120,7 @@ CoordRadial <- ggproto("CoordRadial", Coord, is_free = function() TRUE, - distance = function(self, x, y, details) { + distance = function(self, x, y, details, boost = 0.75) { arc <- details$arc %||% c(0, 2 * pi) if (self$theta == "x") { r <- rescale(y, from = details$r.range, to = self$inner_radius / 0.4) @@ -129,8 +129,8 @@ CoordRadial <- ggproto("CoordRadial", Coord, r <- rescale(x, from = details$r.range, to = self$inner_radius / 0.4) theta <- theta_rescale_no_clip(y, details$theta.range, arc) } - - dist_polar(r, theta) + # The ^boost boosts detailed munching when r is small + dist_polar(r^boost, theta) }, backtransform_range = function(self, panel_params) { From 8190292bf3e1ea7679e35e01eb9b32d7d0ce5628 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Tue, 10 Dec 2024 13:47:06 +0100 Subject: [PATCH 2/3] tweak test --- tests/testthat/test-coord-polar.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-coord-polar.R b/tests/testthat/test-coord-polar.R index 2b07d96b21..1f662d2322 100644 --- a/tests/testthat/test-coord-polar.R +++ b/tests/testthat/test-coord-polar.R @@ -9,7 +9,7 @@ test_that("polar distance is calculated correctly", { ) coord <- coord_polar() panel_params <- coord$setup_panel_params(scales$x, scales$y) - dists <- coord$distance(dat$theta, dat$r, panel_params) + dists <- coord$distance(dat$theta, dat$r, panel_params, boost = 1) # dists is normalized by dividing by this value, so we'll add it back # The maximum length of a spiral arc, from (t,r) = (0,0) to (2*pi,1) From 5e8b7491db1a25ce85d3489050c97ec61dd0b607 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Tue, 10 Dec 2024 13:49:57 +0100 Subject: [PATCH 3/3] accept snapshots --- .../bottom-half-circle-with-rotated-text.svg | 4 +- ...with-axes-placed-at-90-and-225-degrees.svg | 10 +- .../inner-radius-with-all-axes.svg | 44 +-- .../coord-polar/partial-with-all-axes.svg | 46 +-- ...etrack-plot-closed-and-has-center-hole.svg | 6 +- ...cetrack-plot-closed-and-no-center-hole.svg | 6 +- .../rays-circular-arcs-and-spiral-arcs.svg | 285 +++++++++--------- .../rose-plot-with-has-equal-spacing.svg | 4 +- .../coord-polar/three-concentric-circles.svg | 4 +- .../polar-lines-intersect-mid-bars.svg | 12 +- .../open-and-closed-munched-polygons.svg | 8 +- .../_snaps/geom-raster/rectangle-fallback.svg | 8 +- .../_snaps/geom-violin/coord-polar.svg | 2 +- ...xis-theta-with-angle-adapting-to-theta.svg | 96 +++--- .../_snaps/guide-axis/stacked-radial-axes.svg | 42 +-- 15 files changed, 296 insertions(+), 281 deletions(-) diff --git a/tests/testthat/_snaps/coord-polar/bottom-half-circle-with-rotated-text.svg b/tests/testthat/_snaps/coord-polar/bottom-half-circle-with-rotated-text.svg index c01f91abbc..6349bcb350 100644 --- a/tests/testthat/_snaps/coord-polar/bottom-half-circle-with-rotated-text.svg +++ b/tests/testthat/_snaps/coord-polar/bottom-half-circle-with-rotated-text.svg @@ -33,8 +33,8 @@ - - + + diff --git a/tests/testthat/_snaps/coord-polar/full-circle-with-axes-placed-at-90-and-225-degrees.svg b/tests/testthat/_snaps/coord-polar/full-circle-with-axes-placed-at-90-and-225-degrees.svg index 497db8dcf4..46607ddecd 100644 --- a/tests/testthat/_snaps/coord-polar/full-circle-with-axes-placed-at-90-and-225-degrees.svg +++ b/tests/testthat/_snaps/coord-polar/full-circle-with-axes-placed-at-90-and-225-degrees.svg @@ -29,15 +29,15 @@ - - - + + + - - + + diff --git a/tests/testthat/_snaps/coord-polar/inner-radius-with-all-axes.svg b/tests/testthat/_snaps/coord-polar/inner-radius-with-all-axes.svg index b75d829d47..7fddfe8e83 100644 --- a/tests/testthat/_snaps/coord-polar/inner-radius-with-all-axes.svg +++ b/tests/testthat/_snaps/coord-polar/inner-radius-with-all-axes.svg @@ -28,26 +28,26 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - + + + + @@ -97,8 +97,8 @@ - - + + 10 15 20 @@ -111,7 +111,7 @@ - + diff --git a/tests/testthat/_snaps/coord-polar/partial-with-all-axes.svg b/tests/testthat/_snaps/coord-polar/partial-with-all-axes.svg index 03d06791cf..2f1de17be0 100644 --- a/tests/testthat/_snaps/coord-polar/partial-with-all-axes.svg +++ b/tests/testthat/_snaps/coord-polar/partial-with-all-axes.svg @@ -28,26 +28,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -105,8 +105,8 @@ - - + + 100 200 300 @@ -115,7 +115,7 @@ - + diff --git a/tests/testthat/_snaps/coord-polar/racetrack-plot-closed-and-has-center-hole.svg b/tests/testthat/_snaps/coord-polar/racetrack-plot-closed-and-has-center-hole.svg index 8bf3cc6ec2..60045c846f 100644 --- a/tests/testthat/_snaps/coord-polar/racetrack-plot-closed-and-has-center-hole.svg +++ b/tests/testthat/_snaps/coord-polar/racetrack-plot-closed-and-has-center-hole.svg @@ -44,9 +44,9 @@ - - - + + + 1 2 0/3 diff --git a/tests/testthat/_snaps/coord-polar/racetrack-plot-closed-and-no-center-hole.svg b/tests/testthat/_snaps/coord-polar/racetrack-plot-closed-and-no-center-hole.svg index d145a1e446..32bb41821f 100644 --- a/tests/testthat/_snaps/coord-polar/racetrack-plot-closed-and-no-center-hole.svg +++ b/tests/testthat/_snaps/coord-polar/racetrack-plot-closed-and-no-center-hole.svg @@ -44,9 +44,9 @@ - - - + + + 1 2 0/3 diff --git a/tests/testthat/_snaps/coord-polar/rays-circular-arcs-and-spiral-arcs.svg b/tests/testthat/_snaps/coord-polar/rays-circular-arcs-and-spiral-arcs.svg index dfc63cb3d9..0c255f0bb8 100644 --- a/tests/testthat/_snaps/coord-polar/rays-circular-arcs-and-spiral-arcs.svg +++ b/tests/testthat/_snaps/coord-polar/rays-circular-arcs-and-spiral-arcs.svg @@ -47,115 +47,130 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -303,32 +318,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/_snaps/coord-polar/rose-plot-with-has-equal-spacing.svg b/tests/testthat/_snaps/coord-polar/rose-plot-with-has-equal-spacing.svg index b9d09b1835..c82603f417 100644 --- a/tests/testthat/_snaps/coord-polar/rose-plot-with-has-equal-spacing.svg +++ b/tests/testthat/_snaps/coord-polar/rose-plot-with-has-equal-spacing.svg @@ -44,8 +44,8 @@ - - + + A B diff --git a/tests/testthat/_snaps/coord-polar/three-concentric-circles.svg b/tests/testthat/_snaps/coord-polar/three-concentric-circles.svg index e00a3d6a7c..b54b3afc35 100644 --- a/tests/testthat/_snaps/coord-polar/three-concentric-circles.svg +++ b/tests/testthat/_snaps/coord-polar/three-concentric-circles.svg @@ -47,8 +47,8 @@ - - + + 0.25 0.50 diff --git a/tests/testthat/_snaps/geom-hline-vline-abline/polar-lines-intersect-mid-bars.svg b/tests/testthat/_snaps/geom-hline-vline-abline/polar-lines-intersect-mid-bars.svg index 2f67080988..4bd4970011 100644 --- a/tests/testthat/_snaps/geom-hline-vline-abline/polar-lines-intersect-mid-bars.svg +++ b/tests/testthat/_snaps/geom-hline-vline-abline/polar-lines-intersect-mid-bars.svg @@ -36,10 +36,10 @@ - - - - + + + + @@ -47,8 +47,8 @@ - - + + A B C diff --git a/tests/testthat/_snaps/geom-polygon/open-and-closed-munched-polygons.svg b/tests/testthat/_snaps/geom-polygon/open-and-closed-munched-polygons.svg index b970c9f317..5080746f6c 100644 --- a/tests/testthat/_snaps/geom-polygon/open-and-closed-munched-polygons.svg +++ b/tests/testthat/_snaps/geom-polygon/open-and-closed-munched-polygons.svg @@ -25,10 +25,10 @@ - - - - + + + + colour diff --git a/tests/testthat/_snaps/geom-raster/rectangle-fallback.svg b/tests/testthat/_snaps/geom-raster/rectangle-fallback.svg index efb96b5c87..9a3ee13ab3 100644 --- a/tests/testthat/_snaps/geom-raster/rectangle-fallback.svg +++ b/tests/testthat/_snaps/geom-raster/rectangle-fallback.svg @@ -36,10 +36,10 @@ - - - - + + + + 1.0 1.5 2.0 diff --git a/tests/testthat/_snaps/geom-violin/coord-polar.svg b/tests/testthat/_snaps/geom-violin/coord-polar.svg index e70e3b11f3..91c550f802 100644 --- a/tests/testthat/_snaps/geom-violin/coord-polar.svg +++ b/tests/testthat/_snaps/geom-violin/coord-polar.svg @@ -38,7 +38,7 @@ - + A B C diff --git a/tests/testthat/_snaps/guide-axis/guide-axis-theta-with-angle-adapting-to-theta.svg b/tests/testthat/_snaps/guide-axis/guide-axis-theta-with-angle-adapting-to-theta.svg index 48b903c6f3..79f3e27b8c 100644 --- a/tests/testthat/_snaps/guide-axis/guide-axis-theta-with-angle-adapting-to-theta.svg +++ b/tests/testthat/_snaps/guide-axis/guide-axis-theta-with-angle-adapting-to-theta.svg @@ -28,53 +28,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + @@ -176,8 +176,8 @@ - - + + 10 15 20 diff --git a/tests/testthat/_snaps/guide-axis/stacked-radial-axes.svg b/tests/testthat/_snaps/guide-axis/stacked-radial-axes.svg index 9b4cf580e7..d8399aeb76 100644 --- a/tests/testthat/_snaps/guide-axis/stacked-radial-axes.svg +++ b/tests/testthat/_snaps/guide-axis/stacked-radial-axes.svg @@ -28,21 +28,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -95,15 +95,15 @@ - + 100 200 300 - - + + 100 200 300 @@ -112,7 +112,7 @@ - + 100 200 300 @@ -121,7 +121,7 @@ - + @@ -130,7 +130,7 @@ 200 300 400 - +