From 586c011422a5f47f06f3b742fea428b90478595a Mon Sep 17 00:00:00 2001 From: Kyungdahm Yun Date: Thu, 2 Jul 2020 20:15:59 -0700 Subject: [PATCH] Support custom `names` in visualize(S, x, y) with group --- src/util/visualize.jl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/util/visualize.jl b/src/util/visualize.jl index 5b611e0d..17fd9179 100644 --- a/src/util/visualize.jl +++ b/src/util/visualize.jl @@ -1,13 +1,18 @@ visualize(S::Type{<:System}, x, y; config=(), group=(), xstep=(), stop=nothing, skipfirst=true, filter=nothing, - ylab=nothing, legend=nothing, plotopts... + ylab=nothing, legend=nothing, names=nothing, plotopts... ) = begin G = configure(group) C = @config config + !G - if isempty(G) - names = [""] + names = if !isnothing(names) + names + elseif isempty(G) + [""] + elseif G isa Vector + # temporary numeric labels + string.(1:length(G)) else K, V = only(G) k, v = only(V) @@ -16,7 +21,7 @@ visualize(S::Type{<:System}, x, y; T = K == Symbol(0) ? S : type(K) u = fieldtype(T, k) |> unit !isnothing(u) && (legend *= " ($u)") - names = string.(v) + string.(v) end isnothing(ylab) && (ylab = y)