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

allow transformation functions in Cycled #2404

Closed
wants to merge 5 commits into from

Conversation

jkrumbiegel
Copy link
Member

@jkrumbiegel jkrumbiegel commented Nov 6, 2022

Description

Fixes #1629

Allows to pass any kind of transformation function for Cycled, this can be used to give colors a different alpha, for example.

Type of change

Delete options that do not apply:

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

Example

f = Figure()

Axis(f[1, 1])

# the normal cycle
lines!(0..10, x -> sin(x) - 1)
lines!(0..10, x -> sin(x) - 2)
lines!(0..10, x -> sin(x) - 3)

# manually specified colors
lines!(0..10, x -> sin(x) - 5, color = Cycled(3))
lines!(0..10, x -> sin(x) - 6, color = Cycled(2))
lines!(0..10, x -> sin(x) - 7, color = Cycled(1))
lines!(0..10, x -> sin(x) - 8, color = Cycled(x -> (x, 0.5), 1))

f

grafik

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.

@MakieBot
Copy link
Collaborator

MakieBot commented Nov 6, 2022

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 11.02s (10.94, 11.09) 0.06+- 1.15s (1.13, 1.16) 0.01+- 833.02ms (813.24, 889.18) 25.40+- 10.68ms (10.62, 10.79) 0.06+- 92.99ms (92.01, 93.59) 0.51+-
master 11.07s (10.97, 11.21) 0.09+- 1.15s (1.13, 1.17) 0.01+- 816.32ms (772.50, 836.95) 20.95+- 10.74ms (10.65, 10.90) 0.09+- 92.54ms (91.74, 93.54) 0.66+-
evaluation -0.47%, -0.05s invariant (-0.67d, 0.24p, 0.08std) -0.25%, -0.0s invariant (-0.22d, 0.69p, 0.01std) +2.00%, 16.7ms invariant (0.72d, 0.21p, 23.17std) -0.57%, -0.06ms invariant (-0.82d, 0.15p, 0.07std) +0.48%, 0.45ms invariant (0.76d, 0.18p, 0.58std)
CairoMakie 8.38s (8.23, 8.68) 0.15+- 1.13s (1.10, 1.21) 0.04+- 246.12ms (241.02, 258.17) 5.68+- 9.17ms (9.04, 9.29) 0.09+- 5.22ms (5.13, 5.30) 0.06+-
master 8.34s (8.21, 8.44) 0.08+- 1.14s (1.12, 1.15) 0.01+- 256.47ms (251.57, 264.45) 4.43+- 9.19ms (9.06, 9.40) 0.10+- 5.30ms (5.18, 5.57) 0.13+-
evaluation +0.53%, 0.04s invariant (0.37d, 0.51p, 0.12std) -0.29%, -0.0s invariant (-0.12d, 0.83p, 0.02std) -4.20%, -10.35ms faster ✓ (-2.03d, 0.00p, 5.05std) -0.25%, -0.02ms invariant (-0.24d, 0.67p, 0.10std) -1.55%, -0.08ms invariant (-0.80d, 0.17p, 0.10std)
WGLMakie 10.48s (10.41, 10.58) 0.07+- 1.22s (1.18, 1.24) 0.02+- 11.31s (11.22, 11.44) 0.07+- 12.84ms (12.17, 15.28) 1.11+- 812.79ms (776.90, 876.05) 31.16+-
master 10.44s (10.35, 10.52) 0.08+- 1.24s (1.17, 1.31) 0.04+- 11.37s (11.32, 11.45) 0.05+- 12.33ms (11.91, 12.74) 0.33+- 809.36ms (784.83, 840.62) 22.41+-
evaluation +0.36%, 0.04s invariant (0.51d, 0.36p, 0.07std) -1.60%, -0.02s invariant (-0.58d, 0.31p, 0.03std) -0.51%, -0.06s invariant (-0.92d, 0.11p, 0.06std) +3.94%, 0.51ms invariant (0.62d, 0.28p, 0.72std) +0.42%, 3.43ms invariant (0.13d, 0.82p, 26.78std)

@SimonDanisch
Copy link
Member

I can't think of many more sane applications then adding alpha. Therefore, could this be solved by: #2900?

@ForceBru
Copy link

ForceBru commented Jun 9, 2024

I can't think of many more sane applications then adding alpha. Therefore, could this be solved by: #2900?

@SimonDanisch, how can one use #2900 to solve this? I'm using CairoMakie v0.12.2 and getting the same errors as in #1629:

ERROR: MethodError: no method matching to_color(::Makie.Cycled)

Closest candidates are:
  to_color(::Symbol)
   @ Makie ~/.julia/packages/Makie/We6MY/src/conversions.jl:872
  to_color(::Makie.Palette)
   @ Makie ~/.julia/packages/Makie/We6MY/src/conversions.jl:863
  to_color(::Makie.Scene, ::Any, ::Makie.Cycled)
   @ Makie ~/.julia/packages/Makie/We6MY/src/makielayout/blocks/axis.jl:705
  ...

Is there any fix for this?

@SimonDanisch
Copy link
Member

Closing, since alpha kw seems to solve most use cases.

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.

Allow (Cycled(n), α)
5 participants