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... )
2418end
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... )
2822end
2923
@@ -64,7 +58,7 @@ A series of XYVectors, or a single xyvector.
6458"""
6559const 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
9387end
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)
10498end
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)
117111end
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
153147end
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
205199end
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
261255end
@@ -282,15 +276,15 @@ function text_attributes(values, groups, bar_colors, bg_color, text_color)
282276 return aligns, offsets, text_colors
283277end
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,
340334end
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
346340Plot 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... )
351345end
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),
428422end
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 ])
437431end
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
448442Lighthouse 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"""
473467function plot_reliability_calibration_curves (args... ; kw... )
@@ -489,11 +483,11 @@ function plot_binary_discrimination_calibration_curves(args...; kw...)
489483end
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
504498plot_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...)
522516plot_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"""
533527plot_kappas (args... ; kw... ) = axisplot (plot_kappas!, args; kw... )
0 commit comments