From 40cb13395d18ad6f8fa462a5b120e6068e5699b8 Mon Sep 17 00:00:00 2001 From: Helmut Haensel Date: Wed, 20 May 2020 10:55:14 +0200 Subject: [PATCH] support extra_plot_kwargs in plotly backend --- src/backends/plotly.jl | 2 +- src/utils.jl | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index b63213b5..e2cb2448 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -336,7 +336,7 @@ function plotly_layout(plt::Plot) plotattributes_out[:hovermode] = "none" end - plotattributes_out + plotattributes_out = recursive_merge(plotattributes_out, plt.attr[:extra_plot_kwargs]) end function plotly_layout_json(plt::Plot) diff --git a/src/utils.jl b/src/utils.jl index d24ed3a7..5bc022d4 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -302,6 +302,11 @@ Base.convert(::Type{Vector{T}}, rng::AbstractRange{S}) where {T<:Real,S<:Real} = Base.merge(a::AbstractVector, b::AbstractVector) = sort(unique(vcat(a,b))) +# recursively merge kw-dicts, e.g. for merging extra_kwargs / extra_plot_kwargs in plotly) +recursive_merge(x::AbstractDict...) = merge(recursive_merge, x...) +# if values are not AbstractDicts, take the last definition (as does merge) +recursive_merge(x...) = x[end] + nanpush!(a::AbstractVector, b) = (push!(a, NaN); push!(a, b)) nanappend!(a::AbstractVector, b) = (push!(a, NaN); append!(a, b))