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 band to pass the alpha attribute to its mesh #3613

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

Conversation

asinghvi17
Copy link
Member

Description

Fixes #3356

Just forwards the attribute to mesh called internally in plot!(band).

Type of change

Delete options that do not apply:

  • Bug fix (non-breaking change which fixes an issue)

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 Feb 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.42s (3.35, 3.56) 0.07+- 391.14ms (378.35, 414.87) 13.57+- 480.59ms (465.92, 513.17) 16.68+- 7.27ms (7.12, 7.46) 0.13+- 25.57ms (25.25, 26.06) 0.25+-
master 3.43s (3.36, 3.56) 0.07+- 404.46ms (395.13, 420.74) 8.86+- 479.16ms (465.64, 510.30) 14.94+- 7.28ms (7.07, 7.79) 0.26+- 25.54ms (25.25, 26.25) 0.34+-
evaluation 1.00x invariant, -0.0s (-0.02d, 0.97p, 0.07std) 1.03x invariant, -13.32ms (-1.16d, 0.05p, 11.21std) 1.00x invariant, 1.43ms (0.09d, 0.87p, 15.81std) 1.00x invariant, -0.01ms (-0.05d, 0.93p, 0.19std) 1.00x invariant, 0.03ms (0.10d, 0.85p, 0.30std)
CairoMakie 3.05s (3.02, 3.10) 0.03+- 317.65ms (312.97, 323.23) 3.65+- 142.35ms (139.23, 145.96) 2.40+- 7.42ms (7.33, 7.51) 0.06+- 607.72μs (604.43, 611.40) 2.47+-
master 3.06s (3.01, 3.10) 0.04+- 325.78ms (315.26, 344.16) 10.43+- 142.22ms (140.07, 145.90) 2.05+- 7.50ms (7.32, 7.76) 0.13+- 614.18μs (610.65, 618.23) 2.63+-
evaluation 1.00x invariant, -0.0s (-0.07d, 0.90p, 0.03std) 1.03x invariant, -8.13ms (-1.04d, 0.09p, 7.04std) 1.00x invariant, 0.12ms (0.06d, 0.92p, 2.23std) 1.01x invariant, -0.08ms (-0.76d, 0.19p, 0.10std) 1.01x faster ✓, -6.46μs (-2.53d, 0.00p, 2.55std)
WGLMakie 3.81s (3.77, 3.86) 0.03+- 337.85ms (330.21, 341.64) 4.14+- 9.45s (9.27, 10.14) 0.31+- 9.86ms (9.55, 10.98) 0.50+- 74.62ms (68.13, 83.87) 6.54+-
master 3.79s (3.75, 3.84) 0.03+- 339.25ms (334.26, 346.35) 4.12+- 9.49s (9.35, 9.60) 0.11+- 9.58ms (9.39, 9.78) 0.11+- 75.20ms (69.80, 82.27) 5.09+-
evaluation 0.99x invariant, 0.02s (0.67d, 0.24p, 0.03std) 1.00x invariant, -1.4ms (-0.34d, 0.54p, 4.13std) 1.00x invariant, -0.04s (-0.19d, 0.74p, 0.21std) 0.97x invariant, 0.29ms (0.79d, 0.19p, 0.31std) 1.01x invariant, -0.58ms (-0.10d, 0.86p, 5.81std)

@@ -54,6 +54,7 @@ function Makie.plot!(plot::Band)
end
attr = Attributes(plot)
attr[:color] = meshcolor
attr[:alpha] = plot.alpha
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't Attributes(plot) already be doing this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can check, but it wasn't before

Copy link
Member Author

@asinghvi17 asinghvi17 Feb 8, 2024

Choose a reason for hiding this comment

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

Ah, I'm not sure what the intention was here - this calls Attributes the constructor, which I think makes sense, but there's an attributes method which gives plot.attributes.

@t-bltg t-bltg added the bug label Feb 15, 2024
Copy link
Collaborator

@ffreyer ffreyer left a comment

Choose a reason for hiding this comment

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

This isn't an issue of attribute pass through. It's probably

color = to_cairo_color(band.color[], band)
not using/generating calculated_colors. (Those probably need to be generated in the backend.) This may also apply to the other override. Would be good to check.

This uses the `calculated_color` components of the mesh of poly and band as the actual color, to allow `alpha` etc to be respected.
@asinghvi17
Copy link
Member Author

Huh, you're right @ffreyer...thing is that poly doesn't actually have a calculated_color, since it doesn't define a calculated_attributes! method at all. I would guess the only reason it works in other backends is because it decomposes to mesh which does that color handling.

I've pushed a commit which handles this for all CairoMakie overrides - let's see if it works!

It decomposes into a flat vector of color per vertex, even with vectors of polygons, or multipolygons.
@ffreyer
Copy link
Collaborator

ffreyer commented Feb 21, 2024

Yea, the other backends rely on calculated colors of the primitive plots. CairoMakie should more or less repeat that work in whatever way it needs. We should check that after this pr the following work:

  • alpha with a flat color (symbol, RGB, RGBA)
  • alpha with vector of colors
  • vectors of values (colormap sampling)
  • changing colormap
  • changing colorrange
  • alpha with vector of values

On master only alpha + flat color seems to be broken.

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

Successfully merging this pull request may close these issues.

Band plot ignores alpha keyword
4 participants