|
1 |
| -import Base: getindex, setindex!, push!, keys |
| 1 | +using RecipesBase |
| 2 | + |
| 3 | +import Base: getindex, setindex!, push!, keys |
2 | 4 |
|
3 | 5 | export ConvergenceHistory
|
4 | 6 | export nprods, niters, nrests
|
5 | 7 |
|
6 |
| -using UnicodePlots |
7 |
| - |
8 | 8 | ########
|
9 | 9 | # Type #
|
10 | 10 | ########
|
@@ -259,71 +259,6 @@ such objects.
|
259 | 259 | plotable(::VecOrMat{T}) where {T <: Real} = true
|
260 | 260 | plotable(::Any) = false
|
261 | 261 |
|
262 |
| -# inner plots |
263 |
| - |
264 |
| -""" |
265 |
| - showplot(ch) |
266 |
| -
|
267 |
| -Print all plotable information inside `ConvergenceHistory` `ch`. |
268 |
| -""" |
269 |
| -function showplot(ch::ConvergenceHistory) |
270 |
| - candidates = collect(values(ch.data)) |
271 |
| - plotables = convert(Vector{Bool},map(plotable, candidates)) |
272 |
| - n = length(filter(identity, plotables)) |
273 |
| - n > 0 || return |
274 |
| - println("\n") |
275 |
| - for (name, draw) in collect(ch.data)[plotables] |
276 |
| - restart = isa(ch, UnrestartedHistory) ? ch.iters : ch.restart |
277 |
| - drawing = plot_collection(draw, ch.iters, restart; name=string(name)) |
278 |
| - println("$drawing\n\n") |
279 |
| - end |
280 |
| -end |
281 |
| - |
282 |
| -""" |
283 |
| - plot_collection(x) |
284 |
| -
|
285 |
| -Build a `UnicodePlot.Plot` object from the plotable collection `x`. |
286 |
| -If `x` is a vector, a series will be made. In case of being a matrix an scatterplot |
287 |
| -will be returned. |
288 |
| -""" |
289 |
| -function plot_collection(vals::Vector{T}, iters::Int, gap::Int; |
290 |
| - restarts=Int(ceil(iters/gap)), color::Symbol=:blue, name::AbstractString="", |
291 |
| - title::AbstractString="", left::Int=1 |
292 |
| - ) where {T <: Real} |
293 |
| - maxy = round(maximum(vals),2) |
294 |
| - miny = round(minimum(vals),2) |
295 |
| - plot = lineplot([left],[miny],xlim=[left,iters],ylim=[miny,maxy],title=title,name=name) |
296 |
| - right = min(left+gap-1,iters) |
297 |
| - lineplot!(plot,collect(left:right),vals[left:right],color=color) |
298 |
| - for restart in 2:restarts |
299 |
| - left+=gap |
300 |
| - right = min(left+gap-1,iters) |
301 |
| - lineplot!(plot,collect(left:right),vals[left:right],color=color) |
302 |
| - lineplot!(plot,[left,left],[miny,maxy], color=:white) |
303 |
| - end |
304 |
| - plot |
305 |
| -end |
306 |
| -function plot_collection(vals::Matrix{T}, iters::Int, gap::Int; |
307 |
| - restarts=Int(ceil(iters/gap)), color::Symbol=:blue, name::AbstractString="", |
308 |
| - title::AbstractString="", left::Int=1 |
309 |
| - ) where {T <: Real} |
310 |
| - n = size(vals,2) |
311 |
| - maxy = round(maximum(vals),2) |
312 |
| - miny = round(minimum(vals),2) |
313 |
| - plot = scatterplot([left],[miny],xlim=[left,iters],ylim=[miny,maxy],title=title,name=name) |
314 |
| - for i in left:iters |
315 |
| - scatterplot!(plot,[i for j in 1:n],vec(vals[i,1:n]),color=color) |
316 |
| - end |
317 |
| - for restart in 2:restarts |
318 |
| - left+=gap |
319 |
| - lineplot!(plot,[left,left],[miny,maxy], color=:white) |
320 |
| - end |
321 |
| - plot |
322 |
| -end |
323 |
| - |
324 |
| -## Recipes (See Plots.jl tutorial on recipes) |
325 |
| - |
326 |
| -using RecipesBase |
327 | 262 |
|
328 | 263 | # Plot entire ConvergenceHistory. `sep` is the color of the restart separator.
|
329 | 264 | @recipe function chef(ch::CompleteHistory; sep = :white)
|
|
0 commit comments