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

[WIP] Customizable colorrange handling #3688

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

asinghvi17
Copy link
Member

@asinghvi17 asinghvi17 commented Mar 7, 2024

Description

This PR introduces a function evaluate_colorrange, which can be extended by users for their own colorrange types. It currently has dispatches for Automatic and Function input, with the default dispatch converting the given colorrange to Vec2{Float64}.

The objective here is to allow users to pass anything they want to determine the colorrange, so long as it returns appropriate output. This is a completion of one of the points of discussion at MakieCon.

It should now be possible to implement structs for colorranges which must be centered about zero, quantile-based colorranges, and any other metric. In addition, functions like PlotUtils.zscale can be passed freely, or any user-provided function that returns a 2-tuple or similar.

Unfortunately, scaling colormaps about zero such that the center is at zero but the top and bottom halves have different scales is not possible to implement in the framework of this PR - that would have to be a separate colormap object and would involve a lot more handling.

The PR still needs tests and examples, but I want to get an understanding of whether this is the right way to go or not.

Type of change

Delete options that do not apply:

  • New feature (non-breaking change which adds functionality)

Checklist

  • Added an entry in CHANGELOG.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

@asinghvi17 asinghvi17 added enhancement Feature requests and enhancements Makie Backend independent issues (Makie core) labels Mar 7, 2024
@asinghvi17 asinghvi17 self-assigned this Mar 7, 2024
@MakieBot
Copy link
Collaborator

MakieBot commented Mar 7, 2024

Compile Times benchmark

Note, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than the base branch. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running:

using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(fig)
using create display create display
GLMakie 3.43s (3.39, 3.49) 0.04+- 170.95ms (166.85, 182.55) 5.46+- 480.15ms (472.83, 486.87) 5.32+- 7.55ms (7.47, 7.69) 0.08+- 25.99ms (25.78, 26.21) 0.13+-
master 3.42s (3.36, 3.47) 0.04+- 167.96ms (163.65, 171.22) 2.60+- 481.39ms (471.91, 498.74) 9.08+- 7.52ms (7.40, 7.74) 0.12+- 25.95ms (25.62, 26.47) 0.30+-
evaluation 1.00x invariant, 0.02s (0.42d, 0.45p, 0.04std) 0.98x invariant, 2.98ms (0.70d, 0.23p, 4.03std) 1.00x invariant, -1.24ms (-0.17d, 0.76p, 7.20std) 1.00x invariant, 0.03ms (0.32d, 0.56p, 0.10std) 1.00x invariant, 0.04ms (0.17d, 0.76p, 0.21std)
CairoMakie 3.06s (2.99, 3.09) 0.03+- 173.55ms (163.87, 193.41) 9.28+- 104.00ms (99.24, 108.06) 2.78+- 7.36ms (7.28, 7.60) 0.11+- 605.34μs (603.26, 609.29) 2.07+-
master 3.04s (2.96, 3.13) 0.07+- 169.54ms (163.84, 178.95) 5.56+- 102.09ms (99.76, 107.41) 2.52+- 7.50ms (7.22, 7.99) 0.28+- 609.06μs (601.43, 620.36) 6.17+-
evaluation 0.99x invariant, 0.02s (0.33d, 0.55p, 0.05std) 0.98x invariant, 4.01ms (0.52d, 0.35p, 7.42std) 0.98x invariant, 1.91ms (0.72d, 0.20p, 2.65std) 1.02x invariant, -0.14ms (-0.66d, 0.25p, 0.19std) 1.01x invariant, -3.73μs (-0.81d, 0.17p, 4.12std)
WGLMakie 3.59s (3.57, 3.65) 0.03+- 375.33ms (369.38, 384.20) 4.88+- 8.51s (8.43, 8.62) 0.07+- 9.20ms (9.09, 9.35) 0.11+- 68.59ms (67.85, 69.29) 0.44+-
master 3.58s (3.54, 3.61) 0.03+- 372.77ms (370.85, 374.40) 1.43+- 8.50s (8.45, 8.54) 0.03+- 9.21ms (9.13, 9.31) 0.07+- 68.89ms (68.15, 69.45) 0.49+-
evaluation 1.00x invariant, 0.01s (0.33d, 0.55p, 0.03std) 0.99x invariant, 2.56ms (0.71d, 0.23p, 3.16std) 1.00x invariant, 0.01s (0.23d, 0.67p, 0.05std) 1.00x invariant, -0.01ms (-0.10d, 0.86p, 0.09std) 1.00x invariant, -0.3ms (-0.65d, 0.25p, 0.46std)

@asinghvi17
Copy link
Member Author

Docs failures are unrelated - it seems like git push failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests and enhancements Makie Backend independent issues (Makie core)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants