1
- """ Plotting functions for lattices and spins on lattices.
2
- """
1
+ # Plotting functions for lattices and spins on lattices.
3
2
4
3
function _setup_scene (; show_axis= false , ortho= false )
5
- fig = GLMakie . Figure ()
6
- ax = GLMakie . LScene (fig[1 , 1 ]; show_axis)
4
+ fig = Makie . Figure ()
5
+ ax = Makie . LScene (fig[1 , 1 ]; show_axis)
7
6
if ortho
8
- _ = GLMakie . cam3d! (ax. scene, projectiontype= GLMakie . Makie. Orthographic)
7
+ _ = Makie . cam3d! (ax. scene, projectiontype= Makie. Orthographic)
9
8
end
10
9
return fig, ax
11
10
end
12
11
13
12
#=
14
13
function plot_lattice!(ax, lattice::Lattice; colors=:Set1_9, markersize=200, linecolor=:grey, linewidth=1.0, kwargs...)
15
14
unique_types = unique(lattice.types)
16
- colors = GLMakie .resample_cmap(colors, 9)
15
+ colors = Makie .resample_cmap(colors, 9)
17
16
18
17
# Plot markers at each site
19
- pts = GLMakie .Point3f0.(vec(lattice))
18
+ pts = Makie .Point3f0.(vec(lattice))
20
19
for (i, type) in enumerate(unique_types)
21
20
bs = findall(isequal(type), lattice.types)
22
- GLMakie .scatter!(ax, pts; label=type, color=colors[i], markersize=markersize, kwargs...)
21
+ Makie .scatter!(ax, pts; label=type, color=colors[i], markersize=markersize, kwargs...)
23
22
end
24
23
25
24
# For some odd reason, the sites will not appear unless this happens afterwards
@@ -31,7 +30,7 @@ function plot_lattice(lattice::Lattice; kwargs...)
31
30
fig, ax = _setup_scene()
32
31
plot_lattice!(ax, lattice; kwargs...)
33
32
# TODO : Markers are often way too big.
34
- fig[1, 2] = GLMakie .Legend(fig, ax, "Species")
33
+ fig[1, 2] = Makie .Legend(fig, ax, "Species")
35
34
fig
36
35
end
37
36
@@ -48,7 +47,7 @@ colors=:Set1_9, markersize=20, linecolor=:grey, linewidth=1.0, kwargs...
48
47
- `markersize=20` : Sets the size of the atomic sites
49
48
- `colors=:Set1_9` : Sets the colors used for the atomic sites
50
49
51
- Additional keyword arguments are given to `GLMakie .scatter!` which
50
+ Additional keyword arguments are given to `Makie .scatter!` which
52
51
draws the points.
53
52
"""
54
53
plot_lattice(cryst::Crystal, latsize=(3,3,3); kwargs...) = plot_lattice(Lattice(cryst, latsize); kwargs...)
@@ -62,7 +61,7 @@ function plot_bonds(lattice::Lattice, ints::Vector{<:AbstractInteractionCPU};
62
61
# TODO : Make selectable in GUI
63
62
b = 1
64
63
65
- colors = GLMakie .resample_cmap(colors, 8)
64
+ colors = Makie .resample_cmap(colors, 8)
66
65
# Sort interactions so that longer bonds are plotted first
67
66
sorted_ints = sort(
68
67
ints,
@@ -76,36 +75,36 @@ function plot_bonds(lattice::Lattice, ints::Vector{<:AbstractInteractionCPU};
76
75
# Plot the lattice
77
76
plot_lattice!(ax, lattice; kwargs...)
78
77
79
- toggles = Vector{GLMakie .Toggle}()
80
- labels = Vector{GLMakie .Label}()
78
+ toggles = Vector{Makie .Toggle}()
79
+ labels = Vector{Makie .Label}()
81
80
cent_cell = CartesianIndex(div.(lattice.size .+ 1, 2)...)
82
81
cent_pt = lattice[cent_cell, b]
83
82
for (n, int) in enumerate(sorted_ints)
84
83
if !isa(int, AbstractPairIntCPU)
85
84
continue
86
85
end
87
86
88
- pts = Vector{GLMakie .Point3f0}()
87
+ pts = Vector{Makie .Point3f0}()
89
88
for (bond, _) in sublat_bonds(int.bondtable, b)
90
89
new_cell = offsetc(cent_cell, bond.n, lattice.size)
91
90
bond_pt = lattice[new_cell, bond.j]
92
- push!(pts, GLMakie .Point3f0(cent_pt))
93
- push!(pts, GLMakie .Point3f0(bond_pt))
91
+ push!(pts, Makie .Point3f0(cent_pt))
92
+ push!(pts, Makie .Point3f0(bond_pt))
94
93
end
95
94
if length(pts) == 0
96
95
continue
97
96
end
98
97
99
98
color = colors[mod1(n, 8)]
100
- seg = GLMakie .linesegments!(pts; linewidth=bondwidth, label=int.label, color=color)
101
- tog = GLMakie .Toggle(fig, active=true)
102
- GLMakie .connect!(seg.visible, tog.active)
99
+ seg = Makie .linesegments!(pts; linewidth=bondwidth, label=int.label, color=color)
100
+ tog = Makie .Toggle(fig, active=true)
101
+ Makie .connect!(seg.visible, tog.active)
103
102
push!(toggles, tog)
104
- push!(labels, GLMakie .Label(fig, int.label))
103
+ push!(labels, Makie .Label(fig, int.label))
105
104
end
106
- GLMakie .axislegend()
105
+ Makie .axislegend()
107
106
if length(toggles) > 0
108
- fig[1, 2] = GLMakie .grid!(hcat(toggles, labels), tellheight=false)
107
+ fig[1, 2] = Makie .grid!(hcat(toggles, labels), tellheight=false)
109
108
end
110
109
fig
111
110
end
@@ -204,29 +203,29 @@ end
204
203
function plot_cells!(ax, sys::System; color=:grey, linewidth=1.0, kwargs...)
205
204
lattice(i, j, k) = sys.crystal.latvecs * Vec3(i, j, k)
206
205
207
- pts = Vector{GLMakie .Point3f0}()
206
+ pts = Vector{Makie .Point3f0}()
208
207
nx, ny, nz = lattice.size
209
208
for j in 1:ny
210
209
for k in 1:nz
211
210
bot_pt, top_pt = lattice(1, j, k), lattice(nx, j, k)
212
- push!(pts, GLMakie .Point3f0(bot_pt))
213
- push!(pts, GLMakie .Point3f0(top_pt))
211
+ push!(pts, Makie .Point3f0(bot_pt))
212
+ push!(pts, Makie .Point3f0(top_pt))
214
213
end
215
214
for i in 1:nx
216
215
left_pt, right_pt = lattice(i, j, 1), lattice(i, j, nz)
217
- push!(pts, GLMakie .Point3f0(left_pt))
218
- push!(pts, GLMakie .Point3f0(right_pt))
216
+ push!(pts, Makie .Point3f0(left_pt))
217
+ push!(pts, Makie .Point3f0(right_pt))
219
218
end
220
219
end
221
220
for k in 1:nz
222
221
for i in 1:nx
223
222
left_pt, right_pt = lattice(i, 1, k), lattice(i, ny, k)
224
- push!(pts, GLMakie .Point3f0(left_pt))
225
- push!(pts, GLMakie .Point3f0(right_pt))
223
+ push!(pts, Makie .Point3f0(left_pt))
224
+ push!(pts, Makie .Point3f0(right_pt))
226
225
end
227
226
end
228
227
229
- GLMakie .linesegments!(ax, pts; color=color, linewidth=linewidth)
228
+ Makie .linesegments!(ax, pts; color=color, linewidth=linewidth)
230
229
end
231
230
=#
232
231
@@ -240,16 +239,16 @@ end
240
239
plot_spins(sys::System; linecolor=:grey, arrowcolor=:red, linewidth=0.1,
241
240
arrowsize=0.3, arrowlength=1.0, kwargs...)
242
241
243
- Plot the spin configuration defined by `sys`. `kwargs` are passed to `GLMakie .arrows`.
242
+ Plot the spin configuration defined by `sys`. `kwargs` are passed to `Makie .arrows`.
244
243
"""
245
244
function plot_spins (sys:: System ; linecolor= :grey , arrowcolor= :red ,
246
245
linewidth= 0.1 , arrowsize= 0.2 , arrowlength= 0.2 , ortho= false , kwargs... )
247
246
248
247
fig, ax = _setup_scene (; ortho)
249
248
250
- pts = GLMakie . Point3f0 .(spin_vector_origins (sys, arrowlength)[:])
251
- vecs = GLMakie . Vec3f0 .(sys. dipoles[:])
252
- GLMakie . arrows! (
249
+ pts = Makie . Point3f0 .(spin_vector_origins (sys, arrowlength)[:])
250
+ vecs = Makie . Vec3f0 .(sys. dipoles[:])
251
+ Makie . arrows! (
253
252
ax, pts, vecs;
254
253
linecolor, arrowcolor, linewidth, arrowsize,
255
254
lengthscale= arrowlength, kwargs...
@@ -268,7 +267,7 @@ Produce an animation of constant-energy Landau-Lifshitz dynamics of the given `s
268
267
- `Δt::Float64`: The integration timestep size.
269
268
- `nframes::Int`: The number of frames to produce in the animation.
270
269
271
- Other keyword arguments are passed to `GLMakie .arrows`.
270
+ Other keyword arguments are passed to `Makie .arrows`.
272
271
"""
273
272
function anim_integration (
274
273
sys:: System , fname, steps_per_frame, Δt, nframes;
@@ -277,9 +276,9 @@ function anim_integration(
277
276
)
278
277
fig, ax = _setup_scene ()
279
278
280
- pts = GLMakie . Point3f0 .(spin_vector_origins (sys, arrowlength)[:])
281
- vecs = GLMakie . Observable (GLMakie . Vec3f0 .(view (sys. dipoles,:)))
282
- GLMakie . arrows! (
279
+ pts = Makie . Point3f0 .(spin_vector_origins (sys, arrowlength)[:])
280
+ vecs = Makie . Observable (Makie . Vec3f0 .(view (sys. dipoles,:)))
281
+ Makie . arrows! (
283
282
ax, pts, vecs;
284
283
linecolor= linecolor, arrowcolor= arrowcolor, linewidth= linewidth, arrowsize= arrowsize,
285
284
lengthscale= arrowlength, kwargs...
@@ -289,11 +288,11 @@ function anim_integration(
289
288
framerate = 30
290
289
integrator = ImplicitMidpoint (Δt)
291
290
292
- GLMakie . record (fig, fname, 1 : nframes; framerate= framerate) do frame
291
+ Makie . record (fig, fname, 1 : nframes; framerate= framerate) do frame
293
292
for _ in 1 : steps_per_frame
294
293
step! (sys, integrator)
295
294
end
296
- vecs[] = GLMakie . Vec3f0 .(sys. dipoles[:])
295
+ vecs[] = Makie . Vec3f0 .(sys. dipoles[:])
297
296
end
298
297
end
299
298
@@ -310,9 +309,9 @@ function live_integration(
310
309
)
311
310
fig, ax = _setup_scene ()
312
311
313
- pts = GLMakie . Point3f0 .(spin_vector_origins (sys, arrowlength)[:])
314
- vecs = GLMakie . Observable (GLMakie . Vec3f0 .(view (sys. dipoles,:)))
315
- GLMakie . arrows! (
312
+ pts = Makie . Point3f0 .(spin_vector_origins (sys, arrowlength)[:])
313
+ vecs = Makie . Observable (Makie . Vec3f0 .(view (sys. dipoles,:)))
314
+ Makie . arrows! (
316
315
ax, pts, vecs;
317
316
linecolor= linecolor, arrowcolor= arrowcolor, linewidth= linewidth, arrowsize= arrowsize,
318
317
lengthscale= arrowlength, kwargs...
@@ -325,7 +324,7 @@ function live_integration(
325
324
for step in 1 : steps_per_frame
326
325
step! (sys, integrator)
327
326
end
328
- vecs[] = GLMakie . Vec3f0 .(sys. dipoles[:])
327
+ vecs[] = Makie . Vec3f0 .(sys. dipoles[:])
329
328
sleep (1 / framerate)
330
329
end
331
330
end
@@ -342,10 +341,10 @@ function live_langevin_integration(
342
341
arrowlength= 0.2 , λ= 0.1 , framerate= 30 , kwargs...
343
342
)
344
343
fig, ax = _setup_scene (; show_axis= false )
345
- pts = GLMakie . Point3f0 .(spin_vector_origins (sys, arrowlength)[:])
346
- vecs = GLMakie . Observable (GLMakie . Vec3f0 .(view (sys. dipoles,:)))
344
+ pts = Makie . Point3f0 .(spin_vector_origins (sys, arrowlength)[:])
345
+ vecs = Makie . Observable (Makie . Vec3f0 .(view (sys. dipoles,:)))
347
346
348
- GLMakie . arrows! (
347
+ Makie . arrows! (
349
348
ax, pts, vecs;
350
349
linecolor= linecolor, arrowcolor= arrowcolor, linewidth= linewidth, arrowsize= arrowsize,
351
350
lengthscale= arrowlength, kwargs...
@@ -358,7 +357,7 @@ function live_langevin_integration(
358
357
for _ in 1 : steps_per_frame
359
358
step! (sys, integrator)
360
359
end
361
- vecs[] = GLMakie . Vec3f0 .(sys. dipoles[:])
360
+ vecs[] = Makie . Vec3f0 .(sys. dipoles[:])
362
361
sleep (1 / framerate)
363
362
end
364
363
end
@@ -381,23 +380,23 @@ function plot_3d_structure_factor(sfactor::Array{Float64, 5}, iz)
381
380
ky = 1 : sampy* Ly
382
381
ω = 1 : T
383
382
384
- lsgrid = GLMakie . labelslidergrid! (
383
+ lsgrid = Makie . labelslidergrid! (
385
384
fig,
386
385
[" kx" , " ky" , " ω" ],
387
386
[1 : sampx* Lx, 1 : sampy* Ly, 1 : T]
388
387
)
389
388
fig[2 , 1 ] = lsgrid. layout
390
- volslices = GLMakie . volumeslices! (ax, kx, ky, ω, sfactor)
389
+ volslices = Makie . volumeslices! (ax, kx, ky, ω, sfactor)
391
390
392
391
# See: http://makie.juliaplots.org/stable/plotting_functions/volumeslices.html
393
392
sl_yz, sl_xz, sl_xy = lsgrid. sliders
394
- GLMakie . on (sl_yz. value) do v; volslices[:update_yz ][](v) end
395
- GLMakie . on (sl_xz. value) do v; volslices[:update_xz ][](v) end
396
- GLMakie . on (sl_xy. value) do v; volslices[:update_xy ][](v) end
393
+ Makie . on (sl_yz. value) do v; volslices[:update_yz ][](v) end
394
+ Makie . on (sl_xz. value) do v; volslices[:update_xz ][](v) end
395
+ Makie . on (sl_xy. value) do v; volslices[:update_xy ][](v) end
397
396
398
- GLMakie . set_close_to! (sl_yz, .5 Lx)
399
- GLMakie . set_close_to! (sl_xz, .5 Ly)
400
- GLMakie . set_close_to! (sl_xy, .5 T)
397
+ Makie . set_close_to! (sl_yz, .5 Lx)
398
+ Makie . set_close_to! (sl_xz, .5 Ly)
399
+ Makie . set_close_to! (sl_xy, .5 T)
401
400
402
401
fig
403
402
end
0 commit comments