From 7ca32b5edd8dd5cfbde4eadfc16e029fd28a1dc1 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Sat, 12 Jun 2021 09:38:10 +0200 Subject: [PATCH] show ekwargs on `show` (#3567) --- src/plot.jl | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/plot.jl b/src/plot.jl index ae48d907..914dbc9d 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -23,7 +23,38 @@ current(plot::AbstractPlot) = (CURRENT_PLOT.nullableplot = plot) Base.string(plt::Plot) = "Plot{$(plt.backend) n=$(plt.n)}" Base.print(io::IO, plt::Plot) = print(io, string(plt)) -Base.show(io::IO, plt::Plot) = print(io, string(plt)) +function Base.show(io::IO, plt::Plot) + print(io, string(plt)) + sp_ekwargs = getindex.(plt.subplots, :extra_kwargs) + s_ekwargs = getindex.(plt.series_list, :extra_kwargs) + if isempty(plt[:extra_plot_kwargs]) && all(isempty, sp_ekwargs) && all(isempty, s_ekwargs) + return + end + print(io,"\nCaptured extra kwargs:\n") + do_show = true + for (key, value) in plt[:extra_plot_kwargs] + do_show && println(io, " Plot:") + println(io, " "^4, key, ": ", value) + do_show = false + end + do_show = true + for (i, ekwargs) in enumerate(sp_ekwargs) + for (key, value) in ekwargs + do_show && println(io, " SubplotPlot{$i}:") + println(io, " "^4, key, ": ", value) + do_show = false + end + do_show = true + end + for (i, ekwargs) in enumerate(s_ekwargs) + for (key, value) in ekwargs + do_show && println(io, " Series{$i}:") + println(io, " "^4, key, ": ", value) + do_show = false + end + do_show = true + end +end getplot(plt::Plot) = plt getattr(plt::Plot, idx::Int = 1) = plt.attr