Arrows on trajectory as it evolves

I have a curve as it evolves with time, I need to have arrow on the curve something like shown in the figure. It was plotted using Mathematica. Plot not necessarily need not be against time it can be plot of x vs y.

You can do this with Makie. See this thread:

1 Like

With Plots.jl you can plot arrows with

plot(xs, ys, arrow=true)

So you could split up your input data into separate lines (e.g. using NaNs?) and plot arrows like this.

I know about streamplot. It can give the desired answer but I don’t need all the trajectories, I need just specific trajectories.

1 Like

Points are the solution of the differential equation. There are some issues with it.
Issue-1 : If after separating the points for variables from the solution of differential equation and then the plot will not be smooth when compared to the plot which is obtained by directly giving the solution of differential equation as an argument for the plot command.
Issue-2 : Also, the plot becomes disjoint(it was meant to happen) i.e. from where the NaN is placed in the data to the next point. The point before NaN needs to be repeated after the placement of NaN so that plot remains connected.

It sounds like you know about the possible solutions already. You can take one of those and use it as a basis to write exactly the code you need.

If you specify the question more precisely, including a minimal example of what you have already tried, then we can be of more help.

1 Like

The following code puts arrows on top of a parametric curve (x(t),y(t)) in 2D.
It can be easily modified for 3D and/or for arc-length parameterization.

using Dierckx

# returns N points and N scaled-gradients along (xt,yt) equispaced on t
function arrowedcurve(xt,yt,N::Int)
    Nt = length(xt)
    tn = LinRange(1,Nt,N+2)[2:end-1]
    xt, yt = reshape(xt,1,:), reshape(yt,1,:)  # because Dierckx is picky
    spl = ParametricSpline(1:Nt,[xt;yt], k=1)  # use linear if plot code uses linear segments
    zn, dzn = evaluate(spl,tn)', derivative(spl, tn, nu=1)'
    cf = maximum([diff([extrema(xt)...]), diff([extrema(yt)...])])[1]/100
    dzn = cf * dzn ./ sqrt.(sum(abs2,dzn,dims=2))
    return zn, dzn

using Plots; gr()
t = 0:0.02:4π
xt, yt = t .* cos.(t), t .* sin.(t)

zn, dzn = arrowedcurve(xt,yt,12)
plot(xt,yt, c=:red, legend=false, ratio=1)
quiver!(zn[:,1],zn[:,2], quiver=(dzn[:,1],dzn[:,2]), c=:blue)


For equispaced arrows: