Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upcoming scales 1.4.0 release #6172

Open
5 tasks
teunbrand opened this issue Oct 31, 2024 · 3 comments
Open
5 tasks

Upcoming scales 1.4.0 release #6172

teunbrand opened this issue Oct 31, 2024 · 3 comments
Labels
internals 🔎 wip work in progress

Comments

@teunbrand
Copy link
Collaborator

teunbrand commented Oct 31, 2024

The upcoming release of scales (r-lib/scales#474) prompts a few tasks on ggplot2's side.

  • Prepare for future incorporation of breaks_exp() into transform_exp() (Use snapshot expectations for transformation breaks #6171)
  • Remove shims like the following

    ggplot2/R/utilities.R

    Lines 792 to 808 in b29b831

    # Shim for scales/#424
    col_mix <- function(a, b, amount = 0.5) {
    input <- vec_recycle_common(a = a, b = b, amount = amount)
    a <- grDevices::col2rgb(input$a, TRUE)
    b <- grDevices::col2rgb(input$b, TRUE)
    new <- (a * (1 - input$amount) + b * input$amount)
    grDevices::rgb(
    new["red", ], new["green", ], new["blue", ],
    alpha = new["alpha", ], maxColorValue = 255
    )
    }
    on_load({
    if ("col_mix" %in% getNamespaceExports("scales")) {
    col_mix <- scales::col_mix
    }
    })
  • Tweak col_mix() calls to continue to produce the same hex codes, because the shim has a grDevices::rgb() backend while scales::col_mix() is based on {farver}, producing tiny differences.
  • Rework default colour/fill scales to accept new palette specifications (More palette flexibility #6112)
  • Ensure that default palettes can be retrieved from the theme (Scale palettes from theme #5946)
@teunbrand teunbrand added internals 🔎 wip work in progress labels Nov 12, 2024
@yutannihilation
Copy link
Member

yutannihilation commented Nov 26, 2024

I found the dev version of scales breaks most of the visual tests by a subtle difference of fill (w/ CRAN version: #4D4D4D, w/ dev version: #4E4E4E). Is this expected? Do you observe this on your local? (I just tested on my Windows, so this might be platform-specific problem).

diff --git a/tests/testthat/_snaps/aes/alpha-set-in-alpha.svg b/tests/testthat/_snaps/aes/alpha-set-in-alpha.svg
index 218cedbd2..1e08edd47 100644
--- a/tests/testthat/_snaps/aes/alpha-set-in-alpha.svg
+++ b/tests/testthat/_snaps/aes/alpha-set-in-alpha.svg
@@ -31,11 +31,11 @@
 <rect x='45.03' y='22.78' width='669.49' height='522.33' style='stroke-width: 1.07; stroke: #333333;' />
 </g>
 <g clip-path='url(#cpMC4wMHw3MjAuMDB8MC4wMHw1NzYuMDA=)'>
-<text x='40.10' y='548.14' text-anchor='end' style='font-size: 8.80px; fill: #4D4D4D; font-family: sans;' textLength='22.02px' lengthAdjust='spacingAndGlyphs'>0.950</text>
-<text x='40.10' y='417.56' text-anchor='end' style='font-size: 8.80px; fill: #4D4D4D; font-family: sans;' textLength='22.02px' lengthAdjust='spacingAndGlyphs'>0.975</text>
-<text x='40.10' y='286.98' text-anchor='end' style='font-size: 8.80px; fill: #4D4D4D; font-family: sans;' textLength='22.02px' lengthAdjust='spacingAndGlyphs'>1.000</text>
-<text x='40.10' y='156.39' text-anchor='end' style='font-size: 8.80px; fill: #4D4D4D; font-family: sans;' textLength='22.02px' lengthAdjust='spacingAndGlyphs'>1.025</text>
-<text x='40.10' y='25.81' text-anchor='end' style='font-size: 8.80px; fill: #4D4D4D; font-family: sans;' textLength='22.02px' lengthAdjust='spacingAndGlyphs'>1.050</text>
+<text x='40.10' y='548.14' text-anchor='end' style='font-size: 8.80px; fill: #4E4E4E; font-family: sans;' textLength='22.02px' lengthAdjust='spacingAndGlyphs'>0.950</text>
+<text x='40.10' y='417.56' text-anchor='end' style='font-size: 8.80px; fill: #4E4E4E; font-family: sans;' textLength='22.02px' lengthAdjust='spacingAndGlyphs'>0.975</text>
+<text x='40.10' y='286.98' text-anchor='end' style='font-size: 8.80px; fill: #4E4E4E; font-family: sans;' textLength='22.02px' lengthAdjust='spacingAndGlyphs'>1.000</text>
+<text x='40.10' y='156.39' text-anchor='end' style='font-size: 8.80px; fill: #4E4E4E; font-family: sans;' textLength='22.02px' lengthAdjust='spacingAndGlyphs'>1.025</text>
+<text x='40.10' y='25.81' text-anchor='end' style='font-size: 8.80px; fill: #4E4E4E; font-family: sans;' textLength='22.02px' lengthAdjust='spacingAndGlyphs'>1.050</text>
 <polyline points='42.29,545.11 45.03,545.11 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' />
 <polyline points='42.29,414.53 45.03,414.53 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' />
 <polyline points='42.29,283.95 45.03,283.95 ' style='stroke-width: 1.07; stroke: #333333; stroke-linecap: butt;' />

@teunbrand
Copy link
Collaborator Author

teunbrand commented Nov 26, 2024

Yeah this is anticipated in the 'Tweak col_mix() calls ...' bullet. The reason is {scales} uses farver, which is slightly different than the current base shim. I have a branch ready to open a PR once {scales} is released. CRAN ggplot2 shouldn't be affected, as it doesn't use the new theme mechanism that relies on this.

@yutannihilation
Copy link
Member

Ah, thanks for the details! I didn't notice that bullet is about this and there's a plan. Great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internals 🔎 wip work in progress
Projects
None yet
Development

No branches or pull requests

2 participants