From 27ba7932e34623ff872a0efb89dcb0532b80b130 Mon Sep 17 00:00:00 2001 From: hyrodium Date: Mon, 12 Feb 2024 11:52:42 +0900 Subject: [PATCH 1/2] replace `shift_y` with `offset` --- docs/src/math/knotvector.md | 16 ++++++++-------- ext/BasicBSplineRecipesBaseExt.jl | 4 ++-- test/test_Plots.jl | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) 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..6936339d 100644 --- a/ext/BasicBSplineRecipesBaseExt.jl +++ b/ext/BasicBSplineRecipesBaseExt.jl @@ -6,10 +6,10 @@ 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_y=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 diff --git a/test/test_Plots.jl b/test/test_Plots.jl index 36de01a0..4d5489db 100644 --- a/test/test_Plots.jl +++ b/test/test_Plots.jl @@ -54,7 +54,7 @@ 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(P2); label="k2", gap_y=0.01, offset=-0.03, color=:green) path_img = joinpath(dir_out, "bspline_spaces_and_their_knotvectors.png") @test !isfile(path_img) From c0057b1341cf0b03fc9b27b3c25e87d9327ec059 Mon Sep 17 00:00:00 2001 From: hyrodium Date: Mon, 12 Feb 2024 11:53:10 +0900 Subject: [PATCH 2/2] replace `gap_y` with `gap` --- ext/BasicBSplineRecipesBaseExt.jl | 6 +++--- test/test_Plots.jl | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/BasicBSplineRecipesBaseExt.jl b/ext/BasicBSplineRecipesBaseExt.jl index 6936339d..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, offset=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(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 4d5489db..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, offset=-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)