Skip to content

Commit

Permalink
Update plot kwarg (#382)
Browse files Browse the repository at this point in the history
* replace `shift_y` with `offset`

* replace `gap_y` with `gap`
  • Loading branch information
hyrodium authored Feb 12, 2024
1 parent 15c1dee commit 780f0a0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions docs/src/math/knotvector.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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
```
Expand Down
8 changes: 4 additions & 4 deletions ext/BasicBSplineRecipesBaseExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/test_Plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 780f0a0

Please sign in to comment.