From f1417f522e2c726afff2495dc1062350131d07cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helmut=20H=C3=A4nsel?= Date: Tue, 5 Mar 2024 14:09:15 +0100 Subject: [PATCH 1/2] fix xaxis/yaxis rendering, add keyword axes in PlotLayout --- src/Layouts.jl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Layouts.jl b/src/Layouts.jl index 71bff15..818762b 100644 --- a/src/Layouts.jl +++ b/src/Layouts.jl @@ -1089,6 +1089,7 @@ Base.@kwdef mutable struct PlotLayout title::Union{PlotLayoutTitle,Nothing} = nothing xaxis::Union{Vector{PlotLayoutAxis},Nothing} = nothing yaxis::Union{Vector{PlotLayoutAxis},Nothing} = nothing + axes::Union{Vector{PlotLayoutAxis},Nothing} = nothing showlegend::Union{Bool,Nothing} = nothing # true legend::Union{PlotLayoutLegend,Nothing} = nothing @@ -1231,13 +1232,21 @@ function Base.Dict(pl::PlotLayout, fieldname::Union{Symbol,Nothing} = nothing) if pl.xaxis !== nothing - for d in Dict.(pl.xaxis) - merge!(layout, d) + for x in pl.xaxis + x.xy = "x" + merge!(layout, Dict(x)) end end if pl.yaxis !== nothing - for d in Dict.(pl.yaxis) + for y in pl.yaxis + y.xy = "y" + merge!(layout, Dict(y)) + end + end + + if pl.axes !== nothing + for d in Dict.(pl.axes) merge!(layout, d) end end From 2e62696d91bcd3cb111037d77d1334dde1d63553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helmut=20H=C3=A4nsel?= Date: Tue, 5 Mar 2024 15:23:56 +0100 Subject: [PATCH 2/2] avoid overriding of axes, just render them correctly --- src/Layouts.jl | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Layouts.jl b/src/Layouts.jl index 818762b..59dc5fd 100644 --- a/src/Layouts.jl +++ b/src/Layouts.jl @@ -646,7 +646,7 @@ function Base.show(io::IO, la::PlotLayoutAxis) print(io, output) end -function Base.Dict(la::PlotLayoutAxis) +function Base.Dict(la::PlotLayoutAxis, xy::String = "") trace = Dict{Symbol,Any}() if la.title_text !== nothing @@ -666,8 +666,7 @@ function Base.Dict(la::PlotLayoutAxis) :tickcolor, :tickfont, :tickformat, :ticklabelmode, :ticklabelposition, :ticklen, :tickmode, :tickprefix, :ticks, :tickson, :ticksuffix, :ticktext, :tickvals, :tickwidth, :title, :type, :visible, :zeroline, :zerolinecolor, :zerolinewidth]) - - k = Symbol(la.xy * "axis" * ((la.index > 1) ? "$(la.index)" : "")) + k = Symbol(isempty(xy) ? la.xy : xy, "axis", la.index > 1 ? "$(la.index)" : "") Dict(k => d) end @@ -1233,15 +1232,13 @@ function Base.Dict(pl::PlotLayout, fieldname::Union{Symbol,Nothing} = nothing) if pl.xaxis !== nothing for x in pl.xaxis - x.xy = "x" - merge!(layout, Dict(x)) + merge!(layout, Dict(x, "x")) end end if pl.yaxis !== nothing for y in pl.yaxis - y.xy = "y" - merge!(layout, Dict(y)) + merge!(layout, Dict(y, "y")) end end