Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #523 from JuliaPlots/sd/cmap_arrows
Browse files Browse the repository at this point in the history
add colormap atttribute to arrows
  • Loading branch information
SimonDanisch authored Oct 16, 2020
2 parents a9e95de + 7e8740a commit 3cd5db5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/basic_recipes/basic_recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ $(ATTRIBUTES)
linestyle = nothing,
scale = Vec3f0(1),
normalize = false,
lengthscale = 1.0f0
lengthscale = 1.0f0,
colormap = :viridis
)
# connect arrow + linecolor by default
get!(theme, :arrowcolor, theme[:linecolor])
Expand All @@ -227,7 +228,7 @@ end
convert_arguments(::Type{<: Arrows}, x, y, z, u, v, w) = (Point3f0.(x, y, z), Vec3f0.(u, v, w))

function plot!(arrowplot::Arrows{<: Tuple{AbstractVector{<: Point{N, T}}, V}}) where {N, T, V}
@extract arrowplot (points, directions, lengthscale, arrowhead, arrowsize, arrowcolor)
@extract arrowplot (points, directions, lengthscale, arrowhead, arrowsize, arrowcolor, colormap)
headstart = lift(points, directions, lengthscale) do points, directions, s
map(points, directions) do p1, dir
dir = arrowplot[:normalize][] ? StaticArrays.normalize(dir) : dir
Expand All @@ -237,13 +238,13 @@ function plot!(arrowplot::Arrows{<: Tuple{AbstractVector{<: Point{N, T}}, V}}) w
linesegments!(
arrowplot, headstart,
color = arrowplot[:linecolor], linewidth = arrowplot[:linewidth],
linestyle = arrowplot[:linestyle],
linestyle = arrowplot[:linestyle], colormap = colormap,
)
scatterfun(N)(
arrowplot,
lift(x-> last.(x), headstart),
marker = lift(x-> arrow_head(N, x), arrowhead), markersize = arrowsize,
color = arrowcolor, rotations = directions, strokewidth = 0.0,
color = arrowcolor, rotations = directions, strokewidth = 0.0, colormap = colormap,
)
end

Expand Down

0 comments on commit 3cd5db5

Please sign in to comment.