Plots .jl code
using LaTeXStrings, Plots; gr(dpi=600)
const l, r, cθ, δ, fs = 1, 0.25, cosd(45), 0.12, 18
const vs, vxr, vx, vd = (l, 0), (0, l), (0, -l),(l*cθ, -l*cθ)
circle(x) = Shape(map(z -> z .+ (x + l + r, 0), Plots.partialcircle(0, 2π, 100, r)))
function unit_diagram!(x, xi_str, si_str, xri_str, di_str)
plot!(circle(x), c=:black, fill=:black)
quiver!((x+l+2r, 0), quiver=([vs[1]],vs[2]), c=:black, arrow=:closed)
quiver!((x+l+r, l+r), quiver=([vx[1]],vx[2]), c=:black, arrow=:closed)
quiver!((x+l+r, -(l+r)), quiver=([vx[1]],-vx[2]), c=:black, arrow=:closed)
quiver!((x+l+r+r*cθ, -r*cθ), quiver=([vd[1]],vd[2]), c=:black, arrow=:closed)
annotate!(x+l+r-δ/2, -0.8*l, text(xri_str, :right, fs))
annotate!(x+l+r, l+r+δ, text(xi_str, :center, fs))
annotate!(x+2l, δ, text(si_str, :center, fs))
annotate!(x+(l+r)*(1+cθ)+δ, -(l+r)*cθ - δ, text(di_str, :center, fs))
end
function plot_diagram(n, vstr)
p = plot((0,0), ratio=:equal, framestyle=:none, size=(1200,600)) # size=(1200,600)
quiver!((0,0), quiver=([vs[1]],vs[2]), c=:black, arrow=:closed)
annotate!(l/2, δ, text(L"s_0 = 0", :center, fs))
for i in 1:n
si = i == n ? L"s_%$i = 0" : L"s_%$i"
stri = vstr[i]
!isempty(stri) && (stri = " = $stri")
unit_diagram!((i-1)*(l+2r), L"x_%$i%$stri", si, L"xr_%$i", L"d_%$i")
end
return p
end
plot_diagram(5, ["100", "", "", "", ""])