Skip to content

Commit afbce89

Browse files
committed
try to fix multimode stats plots
1 parent 43606e1 commit afbce89

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/Plotting.jl

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import Base: display
1010

1111
GLMakie.set_theme!(GLMakie.Theme(fontsize = 40))
1212

13-
function newfig()
14-
f = GLMakie.Figure()
13+
function newfig(; size=(800,600))
14+
f = GLMakie.Figure(; size)
1515
display(GLMakie.Screen(), f)
1616
f
1717
end
@@ -54,10 +54,10 @@ Create a figure with `N` subplots laid out in a grid that is as close to square
5454
If `portrait` is `true`, try to lay out the grid in portrait orientation (taller than wide),
5555
otherwise landscape (wider than tall).
5656
"""
57-
function subplotgrid(N, portrait=true; colw=4, rowh=2.5, title=nothing)
57+
function subplotgrid(N, portrait=true; colw=350, rowh=250, title=nothing)
5858
cols = ceil(Int, sqrt(N))
5959
rows = ceil(Int, N/cols)
60-
collect(Iterators.product(1:rows,1:cols))
60+
collect(Iterators.product(1:rows,1:cols)), cols*colw, rows*rowh
6161
end
6262

6363
"""
@@ -152,12 +152,12 @@ function stats(output; kwargs...)
152152

153153
Npl = length(pstats)
154154
if Npl > 0
155-
pfig = newfig()
156-
idcs = subplotgrid(Npl)
155+
idcs, width, height = subplotgrid(Npl)
156+
pfig = newfig(size=(width, height))
157157
for n in 1:Npl
158158
data, ylabel = pstats[n]
159-
data = data'
160159
scale = (multimode ? log10 : identity)
160+
data = multimode ? max.(data, 1e-300) : data
161161
ax = GLMakie.Axis(pfig[idcs[n]...]; xlabel="Distance (cm)", ylabel, yscale=scale)
162162
for i in 1:size(data,1)
163163
GLMakie.lines!(z, data[i,:], label=modes[i])
@@ -169,12 +169,12 @@ function stats(output; kwargs...)
169169

170170
Npl = length(fstats)
171171
if Npl > 0
172-
ffig = newfig()
173-
idcs = subplotgrid(Npl)
172+
idcs, width, height = subplotgrid(Npl)
173+
ffig = newfig(size=(width, height))
174174
for n in 1:Npl
175175
data, ylabel = fstats[n]
176-
data = data'
177176
scale = ((multimode && should_log10(data)) ? log10 : identity)
177+
data = (multimode && should_log10(data)) ? max.(data, 1e-300) : data
178178
ax = GLMakie.Axis(ffig[idcs[n]...]; xlabel="Distance (cm)", ylabel, yscale=scale)
179179
for i in 1:size(data,1)
180180
GLMakie.lines!(z, data[i,:], label=modes[i])
@@ -468,8 +468,6 @@ function spec_1D(output, zslice=maximum(output["z"]), specaxis=:λ;
468468
sfig
469469
end
470470

471-
dashes = [:dash, :dot, :dashdot, :dashdotdot, [0.5, 1.0, 1.5, 2.5]]
472-
473471
function _plot_slice_mm(x, y, z, modestrs, xlabel, ylabel, log10=false; fwlabel=false)
474472
pfig = newfig()
475473
scale = (log10 ? Base.log10 : identity)
@@ -489,7 +487,7 @@ function _plot_slice_mm(x, y, z, modestrs, xlabel, ylabel, log10=false; fwlabel=
489487
label *= @sprintf(" [%.2f %s]", fw, "fs")
490488
end
491489
GLMakie.lines!(x, y[:, midx, sidx]; label,
492-
color=line[:color], linestyle=dashes[midx])
490+
color=line[:color], cycle=[:linestyle])
493491
end
494492
end
495493
pfig

0 commit comments

Comments
 (0)