Skip to content

Commit 38c7d5b

Browse files
committed
Fix Makie new API
1 parent f56752c commit 38c7d5b

23 files changed

Lines changed: 203 additions & 208 deletions

Project.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ version = "0.1.0"
66
[deps]
77
AstroIO = "c85a633c-0c3f-44a2-bffe-7f9d0681b3e7"
88
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
9-
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
109
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
1110
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
1211
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
@@ -35,13 +34,12 @@ VideoIO = "d6d074c3-1acf-5d4c-9a43-ef38773959a2"
3534
[compat]
3635
AstroIO = "0.1"
3736
CSV = "0.9"
38-
CairoMakie = "0.6"
3937
ColorSchemes = "3"
4038
Colors = "0.12"
4139
DataFrames = "1"
4240
DocStringExtensions = "0.8"
4341
FileIO = "1"
44-
GLMakie = "0.4"
42+
GLMakie = "0.5"
4543
Images = "0.25"
4644
LaTeXStrings = "1"
4745
LoopVectorization = "0.12"

docs/src/lib/Methods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ plot_makie!
2828
plot_peano
2929
```
3030

31-
## CairoMakie
31+
## GLMakie
3232

3333
```@docs
3434
projection

docs/src/manual/analyse.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,24 @@
22

33
```@example analysis
44
using AstroPlot
5-
scene, layout = plot_profiling("profiling.csv")
6-
scene
5+
fig = plot_profiling("profiling.csv")
76
```
87

98
```@example analysis
10-
scene, layout = plot_energy("energy.csv")
11-
scene
9+
fig = plot_energy("energy.csv")
1210
```
1311

1412
```@example analysis
15-
scene, layout = plot_energy_delta("energy.csv")
16-
scene
13+
fig = plot_energy_delta("energy.csv")
1714
```
1815

1916
```@example analysis
2017
using AstroIO
2118
header, data = read_gadget2("plummer/snapshot_0000.gadget2", uAstro, uGadget2)
2219
23-
scene, layout = plot_densitycurve(data)
24-
scene
20+
fig = plot_densitycurve(data)
2521
```
2622

2723
```@example analysis
28-
scene, layout = plot_rotationcurve(data)
29-
scene
24+
fig = plot_rotationcurve(data)
3025
```

docs/src/manual/mesh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using PhysicalMeshes
77
using AstroPlot
88
99
c = Cube(PVector(0.0,0.0,0.0), PVector(1.0,1.0,1.0))
10-
scene = plot_makie(c, nothing)
10+
fig = plot_makie(c, nothing)
1111
```
1212

1313
## Static Cartesian Mesh

docs/src/manual/snapshots.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@ plot_positionslice("mosaic/", "snapshot_", collect(0:100), ".gadget2", gadget2()
1010
```
1111

1212
```@example snapshots
13-
scene, layout = plot_trajectory(
13+
fig = plot_trajectory(
1414
"plummer/", "snapshot_", collect(0:20:200), [1,2,3], ".gadget2", gadget2(),
1515
)
16-
scene
1716
```
1817

1918
```@example snapshots
20-
ScaleScene, ScaleLayout, LagrangeScene, LagrangeLayout, df = plot_radii(
19+
FigScale, FigLagrange, df = plot_radii(
2120
"plummer/", "snapshot_", collect(0:20:200), ".gadget2", gadget2(),
2221
times = collect(0.0:0.01:0.1) * u"Gyr", title = "Direct Sum const",
2322
)
24-
ScaleScene
23+
FigScale
2524
```
2625

2726
```@example snapshots
28-
LagrangeScene
27+
FigLagrange
2928
```

src/AstroPlot.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ using ProgressMeter
1010
using DataFrames
1111
using CSV
1212
using GLMakie
13-
using CairoMakie
1413
using Colors
1514
using ColorSchemes
1615
using DocStringExtensions

src/PhysicalParticles.jl

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ function estimate_markersize(data, u; xaxis = :x, yaxis = :y)
1212
xMin = getfield(e, Symbol(string(xaxis) * "Min"))
1313
yMax = getfield(e, Symbol(string(yaxis) * "Max"))
1414
yMin = getfield(e, Symbol(string(yaxis) * "Min"))
15-
return estimate_markersize(ustrip(u*u, (xMax - xMin) * (yMax - yMin)))
15+
u2 = isnothing(u) ? nothing : u*u
16+
return estimate_markersize(ustrip(u2, (xMax - xMin) * (yMax - yMin)))
1617
end
1718

1819
"""
@@ -75,46 +76,50 @@ Plot `scatter` data points (in interactive mode)
7576
7677
```julia
7778
d = randn_pvector(50)
78-
plot_makie!(scene, d, nothing)
79+
plot_makie!(fig, d, nothing)
7980
8081
d = randn_pvector(50, u"km")
81-
plot_makie!(scene, d, u"m")
82+
plot_makie!(fig, d, u"m")
8283
```
8384
"""
84-
function plot_makie!(scene, data::Array{T,1}, u::Union{Nothing, Unitful.FreeUnits} = u"kpc";
85+
function plot_makie!(fig, data::Array{T,1}, u::Union{Nothing, Unitful.FreeUnits} = u"kpc";
8586
markersize = estimate_markersize(data, u),
8687
markerspace=SceneSpace,
8788
resolution = (1000, 1000),
8889
kw...
8990
) where T<:PVector
9091
d = [point3(ustrip(u, p)) for p in data]
91-
Makie.scatter!(scene, d; markersize, markerspace, figure = (resolution = resolution,), kw...)
92+
Makie.scatter!(fig, d; markersize, markerspace, figure = (resolution = resolution,), kw...)
9293
end
9394

94-
function plot_makie!(scene, data::Array{T,1}, u::Union{Nothing, Unitful.FreeUnits} = u"kpc";
95+
function plot_makie!(fig, data::Array{T,1}, u::Union{Nothing, Unitful.FreeUnits} = u"kpc";
9596
markersize = estimate_markersize(data, u),
9697
markerspace=SceneSpace,
9798
resolution = (1000, 1000),
9899
kw...
99100
) where T<:AbstractParticle3D
100101
d = [point3(ustrip(u, p.Pos)) for p in data]
101-
Makie.scatter!(scene, d; markersize, markerspace, figure = (resolution = resolution,), kw...)
102+
Makie.scatter!(fig, d; markersize, markerspace, figure = (resolution = resolution,), kw...)
102103
end
103104

104-
function plot_makie!(scene, data::StructArray{T,N,NT,Tu}, u::Union{Nothing, Unitful.FreeUnits} = u"kpc"; kw...) where T<:AbstractParticle3D where N where NT where Tu
105-
plot_makie!(scene, data.Pos, u; kw...)
105+
function plot_makie!(fig, data::StructArray{T,N,NT,Tu}, u::Union{Nothing, Unitful.FreeUnits} = u"kpc"; kw...) where T<:AbstractParticle3D where N where NT where Tu
106+
plot_makie!(fig, data.Pos, u; kw...)
106107
end
107108

108-
function plot_makie!(scene, data::Union{Array{T,N}, StructArray{T,N,NT,Tu}}, collection::Collection, u::Union{Nothing, Unitful.FreeUnits} = u"kpc"; kw...) where T<:AbstractParticle3D where N where NT where Tu
109+
function plot_makie!(fig, data::Union{Array{T,N}, StructArray{T,N,NT,Tu}}, collection::Collection, u::Union{Nothing, Unitful.FreeUnits} = u"kpc"; kw...) where T<:AbstractParticle3D where N where NT where Tu
109110
d = filter(p->p.Collection == collection, data)
110111
if isempty(d)
111112
@warn "No $collection particle found."
112113
return nothing
113114
else
114-
plot_makie!(scene, d, u; kw...)
115+
plot_makie!(fig, d, u; kw...)
115116
end
116117
end
117118

119+
function plot_makie!(fig, data::StructArray{T,N,NT,Tu}, u::Union{Nothing, Unitful.FreeUnits} = u"kpc"; kw...) where T<:AbstractPoint3D where N where NT where Tu
120+
plot_makie!(fig, Array(data), u; kw...)
121+
end
122+
118123
"""
119124
$(TYPEDSIGNATURES)
120125
Scatter plot of points or particles in REPL

src/analyse/density.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ function plot_densitycurve(data, units = uAstro;
8383
savefolder = pwd(),
8484
resolution = (1600, 900),
8585
kw...)
86-
scene, layout = layoutscene(; resolution)
87-
ax = layout[1,1] = GLMakie.Axis(scene; xlabel, ylabel, title)
86+
fig = Figure(; resolution)
87+
ax = GLMakie.Axis(fig[1,1]; xlabel, ylabel, title)
8888
plot_densitycurve!(ax, data, units; savelog, savefolder, kw...)
89-
return scene, layout
89+
return fig
9090
end

src/analyse/energy.jl

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ function plot_energy_kinetic(df::DataFrame;
4343
ylabel = "E [$uEnergy]",
4444
resolution = (1600, 900),
4545
kw...)
46-
scene, layout = layoutscene(; resolution)
47-
ax = layout[1,1] = GLMakie.Axis(scene; xlabel, ylabel, title)
46+
fig = Figure(; resolution)
47+
ax = GLMakie.Axis(fig[1,1]; xlabel, ylabel, title)
4848
plot_energy_kinetic!(ax, df; kw...)
49-
return scene, layout, df
49+
return fig, df
5050
end
5151

5252
"""
@@ -76,10 +76,10 @@ function plot_energy_potential(df::DataFrame;
7676
ylabel = "E [$uEnergy]",
7777
resolution = (1600, 900),
7878
kw...)
79-
scene, layout = layoutscene(; resolution)
80-
ax = layout[1,1] = GLMakie.Axis(scene; xlabel, ylabel, title)
79+
fig = Figure(; resolution)
80+
ax = GLMakie.Axis(fig[1,1]; xlabel, ylabel, title)
8181
plot_energy_potential!(ax, df; kw...)
82-
return scene, layout, df
82+
return fig, df
8383
end
8484

8585
"""
@@ -122,8 +122,8 @@ function plot_energy(df::DataFrame;
122122
valign = :top,
123123
margin = (10, 10, 10, 10),
124124
kw...)
125-
scene, layout = layoutscene(; resolution)
126-
ax = layout[1,1] = GLMakie.Axis(scene; xlabel, ylabel, title)
125+
fig = Figure(; resolution)
126+
ax = GLMakie.Axis(fig[1,1]; xlabel, ylabel, title)
127127

128128
if !hasproperty(df, :energy) && hasproperty(df, :potential) && hasproperty(df, :kinetic)
129129
df.energy = df.potential + df.kinetic
@@ -158,12 +158,12 @@ function plot_energy(df::DataFrame;
158158
end
159159

160160
if length(p) > 1
161-
leg = layout[1,1] = Legend(scene, p, names;
161+
leg = Legend(fig[1,1], p, names;
162162
tellheight, tellwidth, halign, valign, margin,
163163
)
164164
end
165165

166-
return scene, layout, df
166+
return fig, df
167167
end
168168

169169
"""
@@ -240,10 +240,10 @@ function plot_energy_delta(df::DataFrame;
240240
ylabel = "dE$(axisunit(uEnergy))",
241241
resolution = (1600, 900),
242242
kw...)
243-
scene, layout = layoutscene(; resolution)
244-
ax = layout[1,1] = GLMakie.Axis(scene; xlabel, ylabel, title)
243+
fig = Figure(; resolution)
244+
ax = GLMakie.Axis(fig[1,1]; xlabel, ylabel, title)
245245
plot_energy_delta!(ax, df; kw...)
246-
return scene, layout, df
246+
return fig, df
247247
end
248248

249249
"""
@@ -304,7 +304,6 @@ end
304304
"""
305305
$(TYPEDSIGNATURES)
306306
Compute kinetic energy and sum potential energy of particles in each snapshot.
307-
Return a Tuple of `scene` and `layout`
308307
309308
## Arguments
310309
$_common_argument_snapshot

src/analyse/force.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ function plot_force(data, units = uAstro;
8787
title = "Force" * ts,
8888
kw...
8989
)
90-
scene, layout = layoutscene(; resolution)
91-
ax = layout[1,1] = GLMakie.Axis(scene; xlabel, ylabel, title)
90+
fig = Figure(; resolution)
91+
ax = GLMakie.Axis(fig[1,1]; xlabel, ylabel, title)
9292
plot_force!(ax, data, units; savelog, savefolder, markersize, kw...)
93-
return scene, layout
93+
return fig
9494
end

0 commit comments

Comments
 (0)