Skip to content

Commit

Permalink
Transitioned documentation plots to Python{Call,Plot}
Browse files Browse the repository at this point in the history
  • Loading branch information
jagot committed Apr 3, 2023
1 parent 9b6937d commit 331a25a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 38 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,9 @@ jobs:
- run: |
julia --project=docs -e '
using Pkg
pkg"add https://github.com/jagot/Jagot.jl"'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()
pkg"build PyPlot"'
env:
PYTHON: ""
- run: julia --project=docs docs/make.jl
pkg"add https://github.com/jagot/Jagot.jl"'
- uses: julia-actions/julia-docdeploy@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
*.jl.mem
*~
/docs/src/figures/
Manifest.toml
.CondaPkg
2 changes: 2 additions & 0 deletions docs/CondaPkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[deps]
matplotlib = ">=3"
19 changes: 16 additions & 3 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,30 @@
AngularMomentumAlgebra = "0bb1b1ac-0216-11e9-361b-bb110c659ce1"
AtomicLevels = "10933b4c-d60f-11e8-1fc6-bd9035a249a1"
CompactBases = "2c0377a8-7469-4ebd-be0f-82e501f20078"
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
ContinuumArrays = "7ae1f121-cc2c-504b-ac30-9b923412ae5c"
CoulombIntegrals = "42e5845a-f9f1-11e8-0afe-795ea56ed153"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
EnergyExpressions = "f4b57a2e-27c7-11e9-0cb0-edd185b706f6"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
Jagot = "84fb645a-ffa8-56cf-983b-ade63a92b20c"
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
PythonPlot = "274fc56d-3b97-40fa-a1cd-1b4a50311bf9"
QuasiArrays = "c4ea9172-b204-11e9-377d-29865faadc5c"
SolverTraces = "619b3e1a-df4a-11e8-3b0b-a997e0925a8d"

[compat]
AngularMomentumAlgebra = "0.1, 0.2, 0.3"
AtomicLevels = "0.1.3"
CompactBases = "0.3"
CondaPkg = "0.2"
ContinuumArrays = "0.10, 0.11, 0.12"
CoulombIntegrals = "0.1.1"
Documenter = "0.27"
EnergyExpressions = "0.1"
IntervalSets = "0.7"
LazyArrays = "0.22, 1"
PythonCall = "0.9"
PythonPlot = "1"
QuasiArrays = "0.9"
SolverTraces = "0.1"
48 changes: 22 additions & 26 deletions docs/plots.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using PyPlot
using PythonPlot
using Jagot.plotting
plot_style("ggplot")

using PyCall
using PythonCall
Cycler = pyimport("cycler")
plt.rc("axes", prop_cycle=(plt.rcParams["axes.prop_cycle"] +
Cycler.cycler("linestyle", ["-","--",":","-.",":","-","--"])))
pyplot.rc("axes", prop_cycle=(pyplot.rcParams["axes.prop_cycle"] +
Cycler.cycler("linestyle", ["-","--",":","-.",":","-","--"])))

using Statistics
using Random
Expand All @@ -23,29 +23,24 @@ function mean_color(color::String)
mean([c.r,c.g,c.b])
end

mean_color(color::Py) = mean_color(pyconvert(String, color))

lerp(a,b,t) = (1-t)*a + t*b

mean_position(x, ϕ) = ϕ'*Diagonal(x)*ϕ/'ϕ)

function cfigure(fun::Function, figname; clear=true, tight=true, kwargs...)
figure(figname; kwargs...)
clear && clf()
fun()
tight && tight_layout()
end

function csubplot(fun::Function, args...; nox=false, noy=false)
ax = subplot(args...)
fun()
if nox
no_tick_labels(:x)
xlabel("")
end
if noy
no_tick_labels(:y)
ylabel("")
function savedocfig(name,dir="figures")
fig = gcf()
filename = joinpath(@__DIR__, "src", dir, "$(name).svg")
savefig(filename,
transparent=true,
facecolor=fig.get_facecolor())
PythonPlot.close("all")
if isfile(filename)
println("Saved $(name) to $(filename)")
else
@warn "Saving $(name) to $(filename) failed"
end
ax
end

function plot_orbitals(atom::Atom; nrplot=1000, plot_basis=false,
Expand Down Expand Up @@ -120,7 +115,7 @@ function hydrogen()
gst = ground_state(nucleus)
atom = Atom(R, [spin_configurations(gst)[1]], nucleus)
plot_orbitals(atom)
savefig("docs/src/figures/hydrogen.svg")
savedocfig("hydrogen")
end

function helium()
Expand All @@ -142,7 +137,7 @@ function helium()
end
legend(framealpha=0.75,ncol=2)
end
savefig("docs/src/figures/helium.svg")
savedocfig("helium")
end

function beryllium(grid_type)
Expand All @@ -153,7 +148,7 @@ function beryllium(grid_type)
fock = Fock(atom)
optimize!(fock,ω=0.999,ωmax=1-1e-3,scf_method=:arnoldi)
plot_orbitals(atom)
savefig("docs/src/figures/beryllium-$(grid_type).svg")
savedocfig("beryllium-$(grid_type)")
end

macro echo(expr)
Expand All @@ -162,7 +157,8 @@ macro echo(expr)
end

@info "Documentation plots"
mkpath("docs/src/figures")
fig_dir = joinpath(@__DIR__, "src", "figures")
mkpath(fig_dir)
@echo hydrogen()
@echo helium()
@echo beryllium(:fedvr)
Expand Down

0 comments on commit 331a25a

Please sign in to comment.