diff --git a/docs/src/math/knotvector.md b/docs/src/math/knotvector.md index d43193ee..d9e91c9e 100644 --- a/docs/src/math/knotvector.md +++ b/docs/src/math/knotvector.md @@ -46,7 +46,7 @@ A knot vector can be visualized with `Plots.plot`. k1 = KnotVector([0.0, 1.5, 2.5, 5.5, 8.0, 9.0, 9.5, 10.0]) plot(k1; label="k1") k2 = knotvector"1231123" -plot!(k2; label="k2", shift_y=0.5, ylims=(-0.1,1), xticks=0:10) +plot!(k2; label="k2", offset=0.5, ylims=(-0.1,1), xticks=0:10) savefig("knotvector.png") # hide nothing # hide ``` @@ -60,13 +60,13 @@ nothing # hide ```@example math_knotvector k1 = knotvector"1 2 1 11 2 31" k2 = knotvector"113 1 12 2 32 1 1" -plot(k1; shift_y=-0.0, label="k1", xticks=1:18, yticks=nothing, legend=:right) -plot!(k2; shift_y=-0.2, label="k2") -plot!(k1+k2; shift_y=-0.4, label="k1+k2") -plot!(2k1; shift_y=-0.6, label="2k1") -plot!(unique(k1); shift_y=-0.8, label="unique(k1)") -plot!(unique(k2); shift_y=-1.0, label="unique(k2)") -plot!(unique(k1+k2); shift_y=-1.2, label="unique(k1+k2)") +plot(k1; offset=-0.0, label="k1", xticks=1:18, yticks=nothing, legend=:right) +plot!(k2; offset=-0.2, label="k2") +plot!(k1+k2; offset=-0.4, label="k1+k2") +plot!(2k1; offset=-0.6, label="2k1") +plot!(unique(k1); offset=-0.8, label="unique(k1)") +plot!(unique(k2); offset=-1.0, label="unique(k2)") +plot!(unique(k1+k2); offset=-1.2, label="unique(k1+k2)") savefig("knotvector_operations.png") # hide nothing # hide ``` diff --git a/ext/BasicBSplineRecipesBaseExt.jl b/ext/BasicBSplineRecipesBaseExt.jl index d6a73061..8ff5e8c0 100644 --- a/ext/BasicBSplineRecipesBaseExt.jl +++ b/ext/BasicBSplineRecipesBaseExt.jl @@ -6,17 +6,17 @@ import BasicBSpline.AbstractFunctionSpace using StaticArrays # B-spline space -@recipe function f(k::AbstractKnotVector; gap_y=0.02, shift_y=0.0, plane=:xy) +@recipe function f(k::AbstractKnotVector; gap=0.02, offset=0.0, plane=:xy) u = BasicBSpline._vec(k) l = length(u) - v = fill(float(shift_y), l) + v = fill(float(offset), l) for i in 2:l if u[i-1] == u[i] - v[i] = v[i-1] - gap_y + v[i] = v[i-1] - gap end end seriestype := :scatter - delete!(plotattributes, :gap_y) + delete!(plotattributes, :gap) delete!(plotattributes, :plane) if plane === :xy u, v diff --git a/test/test_Plots.jl b/test/test_Plots.jl index 36de01a0..b26a862a 100644 --- a/test/test_Plots.jl +++ b/test/test_Plots.jl @@ -53,8 +53,8 @@ pl = plot(P1, label="P1", color=:red) plot!(P2, label="P2", color=:green) - plot!(knotvector(P1), label="k1", gap_y=0.01, color=:red) - plot!(knotvector(P2); label="k2", gap_y=0.01, shift_y=-0.03, color=:green) + plot!(knotvector(P1), label="k1", gap=0.01, color=:red) + plot!(knotvector(P2); label="k2", gap=0.01, offset=-0.03, color=:green) path_img = joinpath(dir_out, "bspline_spaces_and_their_knotvectors.png") @test !isfile(path_img)