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

Arbitrary coloring functions for streamplot #2002

Merged
merged 12 commits into from
Jul 22, 2023
Merged

Conversation

asinghvi17
Copy link
Member

@asinghvi17 asinghvi17 commented May 31, 2022

Description

Allows the user to change the streamplot's coloring function using color = color_func(x::Point)::Number or ::Colorant.

This is a work in progress but I'm putting it up here as a base - will build on it later.

Type of change

Delete options that do not apply:

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

Checklist

  • Added an entry in NEWS.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.

Not sure if this should be an option for `color` or a separate kwarg.  @lazarusA any thoughts?
@MakieOrg MakieOrg deleted a comment from MakieBot Jan 14, 2023
@MakieBot
Copy link
Collaborator

MakieBot commented Jan 14, 2023

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(display(fig))
using create display create display
GLMakie 13.78s (13.51, 14.11) 0.20+- 1.22s (1.18, 1.25) 0.03+- 864.51ms (839.15, 933.03) 31.55+- 12.21ms (12.01, 12.44) 0.18+- 166.19ms (163.27, 169.16) 2.03+-
master 13.72s (13.50, 13.89) 0.13+- 1.22s (1.20, 1.24) 0.01+- 866.32ms (847.65, 890.10) 17.60+- 12.25ms (12.11, 12.64) 0.20+- 166.17ms (163.13, 171.63) 2.67+-
evaluation +0.44%, 0.06s invariant (0.35d, 0.52p, 0.17std) +0.50%, 0.01s invariant (0.29d, 0.59p, 0.02std) -0.21%, -1.81ms invariant (-0.07d, 0.90p, 24.58std) -0.30%, -0.04ms invariant (-0.19d, 0.73p, 0.19std) +0.01%, 0.02ms invariant (0.01d, 0.99p, 2.35std)
CairoMakie 10.33s (10.23, 10.39) 0.05+- 1.07s (1.07, 1.08) 0.00+- 222.35ms (220.80, 223.90) 1.09+- 10.41ms (10.31, 10.51) 0.07+- 6.15ms (6.03, 6.21) 0.06+-
master 10.33s (10.27, 10.37) 0.04+- 1.07s (1.06, 1.07) 0.00+- 211.24ms (210.04, 212.08) 0.74+- 10.56ms (10.47, 10.62) 0.05+- 6.25ms (6.19, 6.32) 0.04+-
evaluation -0.06%, -0.01s invariant (-0.14d, 0.80p, 0.04std) +0.63%, 0.01s slower X (1.71d, 0.01p, 0.00std) +5.00%, 11.11ms slower X (11.89d, 0.00p, 0.92std) -1.45%, -0.15ms faster ✓ (-2.32d, 0.00p, 0.06std) -1.58%, -0.1ms faster ✓ (-1.89d, 0.01p, 0.05std)
WGLMakie 13.17s (12.90, 13.35) 0.14+- 1.17s (1.13, 1.21) 0.03+- 11.85s (11.75, 11.97) 0.08+- 14.05ms (13.37, 15.12) 0.54+- 1.22s (1.13, 1.47) 0.11+-
master 13.27s (13.05, 13.47) 0.14+- 1.21s (1.18, 1.24) 0.02+- 11.94s (11.79, 12.21) 0.14+- 13.59ms (13.15, 14.57) 0.50+- 1.16s (1.12, 1.21) 0.03+-
evaluation -0.71%, -0.09s invariant (-0.66d, 0.24p, 0.14std) -3.06%, -0.04s faster ✓ (-1.39d, 0.03p, 0.03std) -0.75%, -0.09s invariant (-0.79d, 0.17p, 0.11std) +3.28%, 0.46ms invariant (0.88d, 0.13p, 0.52std) +4.56%, 0.06s invariant (0.66d, 0.26p, 0.07std)

@SimonDanisch
Copy link
Member

@asinghvi17 do you still want to fix this PR?

@asinghvi17
Copy link
Member Author

asinghvi17 commented Jan 14, 2023

I'm not sure where exactly the issue is but will look into it today or tomorrow. Seems to be a type issue so shouldn't be too hard to correct.

Copy link
Member Author

@asinghvi17 asinghvi17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes should fix it - it turned out that color was being set according to the palette, so I changed the attribute to color_func.

src/basic_recipes/streamplot.jl Outdated Show resolved Hide resolved
src/basic_recipes/streamplot.jl Show resolved Hide resolved
src/basic_recipes/streamplot.jl Outdated Show resolved Hide resolved
src/basic_recipes/streamplot.jl Outdated Show resolved Hide resolved
src/basic_recipes/streamplot.jl Outdated Show resolved Hide resolved
src/basic_recipes/streamplot.jl Outdated Show resolved Hide resolved
src/basic_recipes/streamplot.jl Outdated Show resolved Hide resolved
This is because `color` is overridden by the palette, and it's generally more obvious this way in any case.
@asinghvi17 asinghvi17 marked this pull request as ready for review January 15, 2023 12:01
@lazarusA
Copy link
Contributor

@asinghvi17 this looks ok, it does what is suppose to do. But I don't see any tests, so before merging maybe having would be a good idea. And well, the initial idea was to be able to reproduce the plots from here

@SimonDanisch SimonDanisch merged commit aab593f into master Jul 22, 2023
13 checks passed
@SimonDanisch SimonDanisch deleted the as/streamplot branch July 22, 2023 09:29
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.

4 participants