Skip to content

Commit

Permalink
Drop PyPlot dependency (#23)
Browse files Browse the repository at this point in the history
* Handle #22

* Bump patch
  • Loading branch information
henry2004y authored Apr 21, 2023
1 parent a504a59 commit f244b21
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 39 deletions.
4 changes: 1 addition & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
name = "FieldTracer"
uuid = "05065131-34d1-456a-ba22-faf972bb2934"
authors = ["Hongyang Zhou <[email protected]>"]
version = "0.1.7"
version = "0.1.8"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa"
MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

[compat]
Meshes = "0.24, 0.26, 0.27, 0.28"
MuladdMacro = "0.2"
PyPlot = "2.9"
Requires = "1.1"
julia = "1.6"

Expand Down
1 change: 0 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
FieldTracer = "05065131-34d1-456a-ba22-faf972bb2934"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FieldTracer, PyPlot
using FieldTracer
using Documenter

makedocs(;
Expand Down
25 changes: 24 additions & 1 deletion examples/demo_interactive_select.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using PyPlot

"Return x-type magnetic field from 2D potential using auto-differentiation."
function x_type_autodiff(X, Y, B₀, Bg, dx, dy)

Az(x, y) = B₀/2*(x^2/dx^2 - y^2/dy^2)
∇Az(x, y, z) = ForwardDiff.gradient(p -> Az(p[1], p[2]), SVector(x,y,z))
= SVector(0.0, 0.0, 1.0)
Expand All @@ -22,6 +22,29 @@ function x_type_autodiff(X, Y, B₀, Bg, dx, dy)
B
end

"""
add_arrow(line, size=12)
Add an arrow of `size` to the object `line` from Matplotlib. This requires importing PyPlot,
and only works for Line2D.
"""
function add_arrow(line, size=12)
color = line.get_color()
xdata, ydata = line.get_data()

for i = 1:2
start_ind = length(xdata) ÷ 3 * i
end_ind = start_ind + 1
line.axes.annotate("",
xytext=(xdata[start_ind], ydata[start_ind]),
xy=(xdata[end_ind], ydata[end_ind]),
arrowprops=Dict("arrowstyle"=>"-|>", "color"=>color),
size=size
)
end

end

function onclick(event, axs, Bx, By, X, Y)
xs, ys = event.xdata, event.ydata
u0 = [xs, ys]
Expand Down
8 changes: 1 addition & 7 deletions src/FieldTracer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function trace(args...; alg::Algorithm=RK4(), kwargs...)
elseif alg isa Euler
trace2d_euler(args...; kwargs...)
end
else # 3D
else # 3D
if alg isa RK4
trace3d_rk4(args...; kwargs...)
elseif alg isa Euler
Expand All @@ -48,10 +48,4 @@ function trace(args...; alg::Algorithm=RK4(), kwargs...)

end

function __init__()
@require PyPlot="d330b81b-6aea-500a-939a-2ce795aea3ee" begin
include("utility/pyplot.jl")
end
end

end
26 changes: 0 additions & 26 deletions src/utility/pyplot.jl

This file was deleted.

2 comments on commit f244b21

@henry2004y
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/82035

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.8 -m "<description of version>" f244b21cf500d3d682714d449d414ec4fbda264c
git push origin v0.1.8

Please sign in to comment.