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

Scale capability: Use native colour format if the geom prefers it #5033

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Commits on Nov 6, 2022

  1. Configuration menu
    Copy the full SHA
    549fae9 View commit details
    Browse the repository at this point in the history
  2. FEAT/PERF: ScaleContinuous accepts palette capability may_return_na

    We can extend palettes with attributes to improve the mapping efficiency.
    
    With this commit a palette may define an attribute `may_return_na` to `FALSE`.
    If it does, `ScaleContinuous` will assume the palette may not return missing
    values, and it will skip checking for those and replacing them.
    zeehio committed Nov 6, 2022
    Configuration menu
    Copy the full SHA
    99b7c60 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d9e577d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e86c02a View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    04d21e3 View commit details
    Browse the repository at this point in the history
  6. FEAT/PERF: Implement mapping_method support for ScaleContinuous

    ScaleContinous maps values to palette colours as follows:
    
    - unique values are found
    - unique values are mapped to colors
    - colors are matched to the original vector
    
    If most values are unique, we can be faster by simply maping all values to colors,
    without finding and matching unique values first.
    
    In some scenarios the geom can guess or know if that is going to be the case.
    
    The goal of this commit is to let the geom tell the ScaleContinuous scale
    how the mapping from values to colours should be done.
    
    By default the existing "unique" approach is used.
    
    The geom may now specify `scale_params = list(fill=list(mapping_method = "raw"))`
    to tell the scale corresponding to the fill aesthetic to use a "raw" approach
    of mapping values to colours without finding unique values first.
    
    Besides the default "unique" and the new "raw" mapping methods, we also allow
    the geom to ask to use the "binned" approach, where the geom specifies a number
    of intervals to use and the mapping process is as follows:
    
    - values are binned in N intervals
    - intervals are mapped to colors
    
    This approach is "lossy" (we have a maximum of N different colours), but
    this can be much faster and have almost no difference with respect to
    the other mapping methods.
    zeehio committed Nov 6, 2022
    Configuration menu
    Copy the full SHA
    8e365c0 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    afa0d44 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    6513a17 View commit details
    Browse the repository at this point in the history
  9. FEAT: ScaleContinuous can return native colour format

    Some geoms benefit from using native colour format instead
    of the character based colour format.
    
    This commit lets the geoms specify that they prefer native
    format for colours, and gives the responsibility of converting
    into that format to ScaleContinuous.
    
    Since today it is not mandatory for all scales to honor scale_params,
    the geom that requests this will have to verify that the
    color is given in native format anyway, and do the conversion if
    it has not been done here.
    
    However by optionally shifting the responsibility of the conversion
    to the scale we have potential to further optimizations
    zeehio committed Nov 6, 2022
    Configuration menu
    Copy the full SHA
    44a4d08 View commit details
    Browse the repository at this point in the history
  10. PERF: Palette capability: accepts_native_output=TRUE

    If a palette has accepts_native_output=TRUE set as an attribute,
    ScaleContinuous assumes the palette has an optional argument named
    `color_fmt` which can be set to either "character" or "native".
    
    If the geom prefers a native output format and the palette supports
    it, we let the palette take care of it.
    
    The conversion goes from value -> native colour, which is much faster
    than going through an intermediate character representation of
    the colours.
    zeehio committed Nov 6, 2022
    Configuration menu
    Copy the full SHA
    8a18be6 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    fdfd6d9 View commit details
    Browse the repository at this point in the history