Julia has an awesome documentation, including an example for arrows(). However I don’t figure, how to change the colormap that shows the strength of the arrows. I’d like to change it to :bluesreds. If you know how, let me know.
There is a colormap
attribute. The available colormaps are listed here:
https://docs.makie.org/stable/explanations/colors/#colormaps
I modified the script slightly to set the keyword attribute colormap = :bluesreds
as below.
using GLMakie
f = Figure(size = (800, 800))
Axis(f[1, 1], backgroundcolor = "black")
xs = LinRange(0, 2pi, 20)
ys = LinRange(0, 3pi, 20)
us = [sin(x) * cos(y) for x in xs, y in ys]
vs = [-cos(x) * sin(y) for x in xs, y in ys]
strength = vec(sqrt.(us .^ 2 .+ vs .^ 2))
arrows!(xs, ys, us, vs, arrowsize = 10, lengthscale = 0.3,
arrowcolor = strength, linecolor = strength, colormap = :bluesreds)
f
I got the following result.
2 Likes
Great, thank you! I have also tried that, but Visual Studio didn’t show me a picture (only if I remove the colormap attribute). Seems it was a bug. Now where I restarted it all works fine.
Note that within a REPL session, the last f
is very critical. This implicitly invokes the equivalent of display(f)
, which causes the figure to show up.
2 Likes
For this reason I typically wrap my plotting functions in a begin end
block that always ends with fig
so no matter what I change the figure always comes out
1 Like