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

Arrow colors are not updating correctly #1135

Closed
SebastianM-C opened this issue Jul 16, 2021 · 2 comments
Closed

Arrow colors are not updating correctly #1135

SebastianM-C opened this issue Jul 16, 2021 · 2 comments
Labels
bug WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.

Comments

@SebastianM-C
Copy link
Contributor

It looks like the arrowcolor is not updated when the arrows change / update.

MWE:
Consider the following example based on the arrows docs

using WGLMakie

f = Figure(resolution = (800, 800))
Axis(f[1, 1], backgroundcolor = "black")

xs = LinRange(0, 2pi, 20)
ys = LinRange(0, 3pi, 20)
α = Node(0.3)
us = @lift [sin(x) * cos(y) * $α for x in xs, y in ys]
vs = [-cos(x) * sin(y) for x in xs, y in ys]
strength = @lift vec(sqrt.($us .^ 2 .+ vs .^ 2))

arrows!(xs, ys, us, vs, arrowsize = 10, lengthscale = 0.3,
    arrowcolor = strength, linecolor = strength)

f

image

Now if we update the arows

α[] = 0.9

image

Now if we create the figure with α[] = 0.9 from the start
image

Versions:
Makie v0.15.0
WGLMakie v0.4.3

@SebastianM-C
Copy link
Contributor Author

It seems that the bug might be related to WGLMakie, as in GLMakie it's not present.
I obtained
image
after the update directly

@SebastianM-C SebastianM-C added the WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie. label Jul 16, 2021
@SebastianM-C
Copy link
Contributor Author

SebastianM-C commented Jul 16, 2021

It looks like problem is that color range is different for scatter and linesegments in WGLMakie.
MWE

using LinearAlgebra

α = Node(0.3)
pts = rand(Point2f0, 10)
lns = @lift map(pts) do p
    p => Point2f0($α * p)
end
c = @lift $α .* norm.(pts)
f = Figure()
ax = Axis(f[1, 1])
scatter!(ax, pts, marker = '', color=c)
linesegments!(ax, lns, color=c)
f

Edit:

The MWE can be further simplified to

α = Node(0.5)
r = collect(1:4)
c = @lift $α .* r
f, ax, p = scatter(1:2:8, 1:2:8, color=c)
ls = linesegments!(1:8, 1:8, color=c)
Colorbar(f[1,2], p) # we can add colorbars to see the color range more clearly
Colorbar(f[1,3], ls)
f

image

which when we do

α[] = 0.1

image
results in scatter points to be in the high end of the color range which in turn indicates that the color values remained the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.
Projects
None yet
Development

No branches or pull requests

2 participants