Quiver colors in Plots.jl

In Plots quiver is implemented as a recipe which converts the x, y and quiver arguments to coordinates for the arrows separated by NaNs (Plots.jl/recipes.jl at master · JuliaPlots/Plots.jl · GitHub). In your code above you can take a look at the resulting x (and y) coordinates with:

julia> plt[1][1][:x]
44-element Array{Float64,1}:
 NaN  
   0.0
   1.0
 NaN
 NaN
   1.0
   2.0
   ⋮
  10.0
 NaN
 NaN
  10.0
  11.0
 NaN

(Actually we should only separate the lines with a single NaN instead of two here.)
For this data we want to change the color after every four elements. So you can “fix” your plot with:

plt = quiver(x, y, quiver=(u, v), line_z=repeat(c, inner=4), c=:viridis)
2 Likes