Skip to content

Commit 2008c9f

Browse files
authored
bump Makie compat to 0.20 (#108)
* bump Makie compat * bump StatsBase compat
1 parent b1adbe8 commit 2008c9f

File tree

4 files changed

+45
-44
lines changed

4 files changed

+45
-44
lines changed

.github/workflows/CI.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
pull_request:
1010
jobs:
1111
test:
12-
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
12+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - Makie - ${{ matrix.makie }}
1313
runs-on: ${{ matrix.os }}
1414
strategy:
1515
fail-fast: false
@@ -22,6 +22,8 @@ jobs:
2222
- ubuntu-latest
2323
arch:
2424
- x64
25+
makie:
26+
- '0.20'
2527
env:
2628
JULIA_NUM_THREADS: 2
2729
steps:
@@ -37,11 +39,16 @@ jobs:
3739
path: ~/.julia/artifacts
3840
key: ${{ runner.os }}-test-artifacts-${{ hashFiles('**/Project.toml') }}
3941
restore-keys: ${{ runner.os }}-test-artifacts
40-
- uses: julia-actions/julia-buildpkg@v1
42+
- name: "Install Makie and instantiate project"
43+
shell: julia --color=yes --project {0}
44+
run: |
45+
using Pkg
46+
Pkg.add(Pkg.PackageSpec(; name="Makie", version="${{ matrix.makie }}"))
47+
Pkg.instantiate()
4148
- uses: julia-actions/julia-runtest@v1
4249
- name: Percy Upload
4350
uses: percy/exec-action@v0.3.1
44-
if: matrix.version == 1
51+
if: ${{ matrix.version == 1 && matrix.makie == 0.20 }}
4552
with:
4653
custom-command: "npx @percy/cli upload ./test/plot_results"
4754
env:

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Lighthouse"
22
uuid = "ac2c24cd-07f0-4848-96b2-1b82c3ea0e59"
33
authors = ["Beacon Biosignals, Inc."]
4-
version = "0.15.2"
4+
version = "0.16.0"
55

66
[deps]
77
ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd"
@@ -21,11 +21,11 @@ TensorBoardLogger = "899adc3e-224a-11e9-021f-63837185c80f"
2121
[compat]
2222
Arrow = "2.3"
2323
ArrowTypes = "1, 2"
24-
CairoMakie = "0.7, 0.8"
24+
CairoMakie = "0.11"
2525
DataFrames = "1.3"
2626
Legolas = "0.5"
27-
Makie = "0.17.4, 0.18"
28-
StatsBase = "0.33"
27+
Makie = "0.20"
28+
StatsBase = "0.33, 0.34"
2929
Tables = "1.7"
3030
TensorBoardLogger = "0.1"
3131
julia = "1.6"

docs/src/plotting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fig, ax, p = plot_confusion_matrix(confusion, classes)
2626
```
2727

2828
```@example 1
29-
fig = Figure(resolution=(800, 400))
29+
fig = Figure(size=(800, 400))
3030
plot_confusion_matrix!(fig[1, 1], confusion, classes, :Row, annotation_text_size=14)
3131
plot_confusion_matrix!(fig[1, 2], confusion, classes, :Column, annotation_text_size=14)
3232
fig

src/plotting.jl

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
if !isdefined(Makie, :FigurePosition)
2-
const FigurePosition = Makie.GridPosition
3-
get_parent(x::Makie.GridPosition) = x.layout.parent
4-
else
5-
using Makie: FigurePosition
6-
get_parent(x::FigurePosition) = x.fig
7-
end
1+
get_parent(x::Makie.GridPosition) = x.layout.parent
82

93
# We can't rely on inference to always give us fully typed
104
# Vector{<: Number} so we add `{T} where T` to the the mix
@@ -23,7 +17,7 @@ function get_theme(scene, key1::Symbol, key2::Symbol; defaults...)
2317
return get_theme(Makie.get_scene(scene), key1, key2; defaults...)
2418
end
2519

26-
function get_theme(fig::FigurePosition, key1::Symbol, key2::Symbol; defaults...)
20+
function get_theme(fig::GridPosition, key1::Symbol, key2::Symbol; defaults...)
2721
return get_theme(get_parent(fig), key1, key2; defaults...)
2822
end
2923

@@ -64,7 +58,7 @@ A series of XYVectors, or a single xyvector.
6458
"""
6559
const SeriesCurves = Union{XYVector,AbstractVector{<:XYVector}}
6660

67-
function series_plot!(subfig::FigurePosition, per_class_pr_curves::SeriesCurves,
61+
function series_plot!(subfig::GridPosition, per_class_pr_curves::SeriesCurves,
6862
class_labels::Union{Nothing,AbstractVector{String}}; legend=:lt,
6963
title="No title",
7064
xlabel="x label", ylabel="y label", solid_color=nothing,
@@ -92,7 +86,7 @@ function series_plot!(subfig::FigurePosition, per_class_pr_curves::SeriesCurves,
9286
return ax
9387
end
9488

95-
function plot_pr_curves!(subfig::FigurePosition, per_class_pr_curves::SeriesCurves,
89+
function plot_pr_curves!(subfig::GridPosition, per_class_pr_curves::SeriesCurves,
9690
class_labels::Union{Nothing,AbstractVector{String}}; legend=:lt,
9791
title="PR curves",
9892
xlabel="True positive rate", ylabel="Precision",
@@ -103,7 +97,7 @@ function plot_pr_curves!(subfig::FigurePosition, per_class_pr_curves::SeriesCurv
10397
ylabel=ylabel, scatter=scatter, solid_color=solid_color)
10498
end
10599

106-
function plot_roc_curves!(subfig::FigurePosition, per_class_roc_curves::SeriesCurves,
100+
function plot_roc_curves!(subfig::GridPosition, per_class_roc_curves::SeriesCurves,
107101
per_class_roc_aucs::NumberVector,
108102
class_labels::AbstractVector{<:String};
109103
legend=:rb, title="ROC curves", xlabel="False positive rate",
@@ -116,7 +110,7 @@ function plot_roc_curves!(subfig::FigurePosition, per_class_roc_curves::SeriesCu
116110
ylabel=ylabel)
117111
end
118112

119-
function plot_reliability_calibration_curves!(subfig::FigurePosition,
113+
function plot_reliability_calibration_curves!(subfig::GridPosition,
120114
per_class_reliability_calibration_curves::SeriesCurves,
121115
per_class_reliability_calibration_scores::NumberVector,
122116
class_labels::AbstractVector{String};
@@ -152,7 +146,7 @@ function set_from_kw!(theme, key, kw, default)
152146
return
153147
end
154148

155-
function plot_binary_discrimination_calibration_curves!(subfig::FigurePosition,
149+
function plot_binary_discrimination_calibration_curves!(subfig::GridPosition,
156150
calibration_curve::SeriesCurves,
157151
calibration_score,
158152
per_expert_calibration_curves::Union{SeriesCurves,
@@ -204,7 +198,7 @@ function plot_binary_discrimination_calibration_curves!(subfig::FigurePosition,
204198
return ax
205199
end
206200

207-
function plot_confusion_matrix!(subfig::FigurePosition, confusion::NumberMatrix,
201+
function plot_confusion_matrix!(subfig::GridPosition, confusion::NumberMatrix,
208202
class_labels::AbstractVector{String},
209203
normalize_by::Union{Symbol,Nothing}=nothing;
210204
annotation_text_size=20, colormap=:Blues)
@@ -221,7 +215,7 @@ function plot_confusion_matrix!(subfig::FigurePosition, confusion::NumberMatrix,
221215
title = "$(string(normalize_by))-Normalized Confusion"
222216
end
223217
class_indices = 1:nclasses
224-
text_theme = get_theme(subfig, :ConfusionMatrix, :Text; textsize=annotation_text_size)
218+
text_theme = get_theme(subfig, :ConfusionMatrix, :Text; fontsize=annotation_text_size)
225219
heatmap_theme = get_theme(subfig, :ConfusionMatrix, :Heatmap; nan_color=(:black, 0.0))
226220
axis_theme = get_theme(subfig, :ConfusionMatrix, :Axis; xticklabelrotation=pi / 4,
227221
titlealign=:left, title,
@@ -255,7 +249,7 @@ function plot_confusion_matrix!(subfig::FigurePosition, confusion::NumberMatrix,
255249
annos = vec([(string(confusion[i, j]), Point2f(j, i))
256250
for i in class_indices, j in class_indices])
257251
colors = vec([label_color(i, j) for i in class_indices, j in class_indices])
258-
text!(ax, annos; align=(:center, :center), color=colors, textsize=annotation_text_size,
252+
text!(ax, annos; align=(:center, :center), color=colors, fontsize=annotation_text_size,
259253
text_theme...)
260254
return ax
261255
end
@@ -282,15 +276,15 @@ function text_attributes(values, groups, bar_colors, bg_color, text_color)
282276
return aligns, offsets, text_colors
283277
end
284278

285-
function plot_kappas!(subfig::FigurePosition, per_class_kappas::NumberVector,
279+
function plot_kappas!(subfig::GridPosition, per_class_kappas::NumberVector,
286280
class_labels::AbstractVector{String}, per_class_IRA_kappas=nothing;
287281
color=[:lightgrey, :lightblue], annotation_text_size=20)
288282
nclasses = length(class_labels)
289283
axis_theme = get_theme(subfig, :Kappas, :Axis; aspect=AxisAspect(1), titlealign=:left,
290284
xlabel="Cohen's kappa", xticks=[0, 1], yreversed=true,
291285
yticks=(1:nclasses, class_labels))
292286

293-
text_theme = get_theme(subfig, :Kappas, :Text; textsize=annotation_text_size)
287+
text_theme = get_theme(subfig, :Kappas, :Text; fontsize=annotation_text_size)
294288
text_color = to_color(to_value(pop!(text_theme, :color, to_color(:black))))
295289
bars_theme = get_theme(subfig, :Kappas, :BarPlot; color=color)
296290
bar_colors = to_color.(bars_theme.color[])
@@ -340,7 +334,7 @@ function plot_kappas!(subfig::FigurePosition, per_class_kappas::NumberVector,
340334
end
341335

342336
"""
343-
evaluation_metrics_plot(data::Dict; resolution=(1000, 1000), textsize=12)
337+
evaluation_metrics_plot(data::Dict; size=(1000, 1000), fontsize=12)
344338
evaluation_metrics_plot(row::EvaluationV1; kwargs...)
345339
346340
Plot all evaluation metrics generated via [`evaluation_metrics_record`](@ref) and/or
@@ -350,16 +344,16 @@ function evaluation_metrics_plot(data::Dict; kwargs...)
350344
return evaluation_metrics_plot(EvaluationV1(data); kwargs...)
351345
end
352346

353-
function evaluation_metrics_plot(row::EvaluationV1; resolution=(1000, 1000),
354-
textsize=12)
355-
fig = Figure(; resolution=resolution, Axis=(titlesize=17,))
347+
function evaluation_metrics_plot(row::EvaluationV1; size=(1000, 1000),
348+
fontsize=12)
349+
fig = Figure(; size=size, Axis=(titlesize=17,))
356350

357351
# Confusion
358352
plot_confusion_matrix!(fig[1, 1], row.confusion_matrix, row.class_labels,
359353
:Column;
360-
annotation_text_size=textsize)
354+
annotation_text_size=fontsize)
361355
plot_confusion_matrix!(fig[1, 2], row.confusion_matrix, row.class_labels, :Row;
362-
annotation_text_size=textsize)
356+
annotation_text_size=fontsize)
363357
# Kappas
364358
IRA_kappa_data = nothing
365359
multiclass = length(row.class_labels) > 2
@@ -375,7 +369,7 @@ function evaluation_metrics_plot(row::EvaluationV1; resolution=(1000, 1000),
375369
end
376370

377371
plot_kappas!(fig[1, 3], kappa_data, labels, IRA_kappa_data;
378-
annotation_text_size=textsize)
372+
annotation_text_size=fontsize)
379373

380374
# Curves
381375
ax = plot_roc_curves!(fig[2, 1], row.per_class_roc_curves,
@@ -428,21 +422,21 @@ function evaluation_metrics_plot(row::EvaluationV1; resolution=(1000, 1000),
428422
end
429423

430424
# Helper to more easily define the non mutating versions
431-
function axisplot(func, args; resolution=(800, 600), plot_kw...)
432-
fig = Figure(; resolution=resolution)
425+
function axisplot(func, args; size=(800, 600), plot_kw...)
426+
fig = Figure(; size=size)
433427
ax = func(fig[1, 1], args...; plot_kw...)
434428
# ax.plots[1] is not really that great, but there isn't a FigureAxis object right now
435429
# this will need to wait for when we figure out a better recipe integration
436430
return Makie.FigureAxisPlot(fig, ax, ax.scene.plots[1])
437431
end
438432

439433
"""
440-
plot_confusion_matrix!(subfig::FigurePosition, args...; kw...)
434+
plot_confusion_matrix!(subfig::GridPosition, args...; kw...)
441435
442436
plot_confusion_matrix(confusion::AbstractMatrix{<: Number},
443437
class_labels::AbstractVector{String},
444438
normalize_by::Union{Symbol,Nothing}=nothing;
445-
resolution=(800,600), annotation_text_size=20)
439+
size=(800,600), annotation_text_size=20)
446440
447441
448442
Lighthouse plots confusion matrices, which are simple tables
@@ -467,7 +461,7 @@ plot_confusion_matrix(args...; kw...) = axisplot(plot_confusion_matrix!, args; k
467461
plot_reliability_calibration_curves(per_class_reliability_calibration_curves::SeriesCurves,
468462
per_class_reliability_calibration_scores::NumberVector,
469463
class_labels::AbstractVector{String};
470-
legend=:rb, resolution=(800, 600))
464+
legend=:rb, size=(800, 600))
471465
472466
"""
473467
function plot_reliability_calibration_curves(args...; kw...)
@@ -489,11 +483,11 @@ function plot_binary_discrimination_calibration_curves(args...; kw...)
489483
end
490484

491485
"""
492-
plot_pr_curves!(subfig::FigurePosition, args...; kw...)
486+
plot_pr_curves!(subfig::GridPosition, args...; kw...)
493487
494488
plot_pr_curves(per_class_pr_curves::SeriesCurves,
495489
class_labels::AbstractVector{<: String};
496-
resolution=(800, 600),
490+
size=(800, 600),
497491
legend=:lt, title="PR curves",
498492
xlabel="True positive rate", ylabel="Precision",
499493
linewidth=2, scatter=NamedTuple(), color=:darktest)
@@ -504,12 +498,12 @@ end
504498
plot_pr_curves(args...; kw...) = axisplot(plot_pr_curves!, args; kw...)
505499

506500
"""
507-
plot_roc_curves!(subfig::FigurePosition, args...; kw...)
501+
plot_roc_curves!(subfig::GridPosition, args...; kw...)
508502
509503
plot_roc_curves(per_class_roc_curves::SeriesCurves,
510504
per_class_roc_aucs::NumberVector,
511505
class_labels::AbstractVector{<: String};
512-
resolution=(800, 600),
506+
size=(800, 600),
513507
legend=:lt,
514508
title="ROC curves",
515509
xlabel="False positive rate",
@@ -522,12 +516,12 @@ plot_pr_curves(args...; kw...) = axisplot(plot_pr_curves!, args; kw...)
522516
plot_roc_curves(args...; kw...) = axisplot(plot_roc_curves!, args; kw...)
523517

524518
"""
525-
plot_kappas!(subfig::FigurePosition, args...; kw...)
519+
plot_kappas!(subfig::GridPosition, args...; kw...)
526520
527521
plot_kappas(per_class_kappas::NumberVector,
528522
class_labels::AbstractVector{String},
529523
per_class_IRA_kappas=nothing;
530-
resolution=(800, 600),
524+
size=(800, 600),
531525
annotation_text_size=20)
532526
"""
533527
plot_kappas(args...; kw...) = axisplot(plot_kappas!, args; kw...)

0 commit comments

Comments
 (0)