1
- function onlineplot! (scene, layout , axis_dict, stats:: AbstractVector , iter, data, variable, i)
1
+ function onlineplot! (fig , axis_dict, stats:: AbstractVector , iter, data, variable, i)
2
2
for (j, stat) in enumerate (stats)
3
- axis_dict[(variable, stat)] = layout [i, j] = Axis (scene , title = " $(name (stat)) " )
3
+ axis_dict[(variable, stat)] = fig [i, j] = Axis (fig , title= " $(name (stat)) " )
4
4
limits! (axis_dict[(variable, stat)], 0.0 , 10.0 , - 1.0 , 1.0 )
5
5
onlineplot! (axis_dict[(variable, stat)], stat, iter, data[variable], data[:iter ], i, j)
6
6
tight_ticklabel_spacing! (axis_dict[(variable, stat)])
@@ -19,27 +19,26 @@ onlineplot!(axis, ::Val{:autocov}, args...) = onlineplot!(axis, AutoCov(20), arg
19
19
20
20
onlineplot! (axis, :: Val{:hist} , args... ) = onlineplot! (axis, KHist (50 , Float32), args... )
21
21
22
-
23
22
# Generic fallback for OnlineStat objects
24
23
function onlineplot! (axis, stat:: T , iter, data, iterations, i, j) where {T<: OnlineStat }
25
24
window = data. b
26
25
@eval TStat = $ (nameof (T))
27
26
stat = Observable (TStat (Float32))
28
- on (iter) do i
27
+ on (iter) do _
29
28
stat[] = fit! (stat[], last (value (data)))
30
29
end
31
30
statvals = Observable (MovingWindow (window, Float32))
32
31
on (stat) do s
33
32
statvals[] = fit! (statvals[], Float32 (value (s)))
34
33
end
35
- statpoints = lift (statvals; init = Point2f0 .([0 ], [0 ])) do v
34
+ statpoints = map! ( Observable ( Point2f0 .([0 ], [0 ])), statvals) do v
36
35
Point2f0 .(value (iterations), value (v))
37
36
end
38
37
lines! (axis, statpoints, color = std_colors[i], linewidth = 3.0 )
39
38
end
40
39
41
40
function onlineplot! (axis, :: Val{:trace} , iter, data, iterations, i, j)
42
- trace = lift (iter; init = [Point2f0 (0f0 , 0f0 )]) do i
41
+ trace = map! ( Observable ( [Point2f0 (0 , 0 )]), iter) do _
43
42
Point2f0 .(value (iterations), value (data))
44
43
end
45
44
lines! (axis, trace, color = std_colors[i]; linewidth = 3.0 )
48
47
function onlineplot! (axis, stat:: KHist , iter, data, iterations, i, j)
49
48
nbins = stat. k
50
49
stat = Observable (KHist (nbins, Float32))
51
- on (iter) do i
50
+ on (iter) do _
52
51
stat[] = fit! (stat[], last (value (data)))
53
52
end
54
- hist_vals = lift (stat; init = Point2f0 .(range (0 , 1 , length = nbins), zeros (Float32, nbins))) do h
53
+ hist_vals = Node (Point2f0 .(collect (range (0f0 , 1f0 , length= nbins)), zeros (Float32, nbins)))
54
+ on (stat) do h
55
55
edges, weights = OnlineStats. xy (h)
56
56
weights = nobs (h) > 1 ? weights / OnlineStats. area (h) : weights
57
- return Point2f0 .(edges, weights)
57
+ hist_vals[] = Point2f0 .(edges, weights)
58
58
end
59
- barplot! (axis, hist_vals, color = std_colors[i])
59
+ barplot! (axis, hist_vals; color= std_colors[i])
60
+ # barplot!(axis, rand(4), rand(4))
60
61
end
61
62
62
63
function expand_extrema (xs)
69
70
70
71
function onlineplot! (axis, :: Val{:kde} , iter, data, iterations, i, j)
71
72
interpkde = Observable (InterpKDE (kde ([1f0 ])))
72
- on (iter) do i
73
+ on (iter) do _
73
74
interpkde[] = InterpKDE (kde (value (data)))
74
75
end
75
- xs = lift (iter; init = range (0.0 , 2.0 , length = 200 )) do i
76
- range (expand_extrema (extrema (value (data)))... , length = 200 )
76
+ xs = Observable (range (0 , 2 , length= 10 ))
77
+ on (iter) do _
78
+ xs[] = range (expand_extrema (extrema (value (data)))... , length = 200 )
77
79
end
78
80
kde_pdf = lift (xs) do xs
79
81
pdf .(Ref (interpkde[]), xs)
80
82
end
81
83
lines! (axis, xs, kde_pdf, color = std_colors[i], linewidth = 3.0 )
82
84
end
83
85
84
- name (s:: Val{:histkde} ) = " Hist + KDE"
86
+ name (s:: Val{:histkde} ) = " Hist. + KDE"
85
87
86
88
function onlineplot! (axis, :: Val{:histkde} , iter, data, iterations, i, j)
87
89
onlineplot! (axis, KHist (50 ), iter, data, iterations, i, j)
91
93
function onlineplot! (axis, stat:: AutoCov , iter, data, iterations, i, j)
92
94
b = length (stat. cross)
93
95
stat = Observable (AutoCov (b, Float32))
94
- on (iter) do i
96
+ on (iter) do _
95
97
stat[] = fit! (stat[], last (value (data)))
96
98
end
97
- statvals = lift (stat; init = zeros (Float32, b + 1 )) do s
99
+ statvals = map! ( Observable ( zeros (Float32, b + 1 )), stat ) do s
98
100
value (s)
99
101
end
100
102
scatter! (axis, Point2f0 .([0.0 , b], [- 0.1 , 1.0 ]), markersize = 0.0 , color = RGBA (0.0 , 0.0 , 0.0 , 0.0 )) # Invisible points to keep limits fixed
0 commit comments