Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix xaxis/yaxis rendering, add keyword axes in PlotLayout #70

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/Layouts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -1089,6 +1088,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
Expand Down Expand Up @@ -1231,13 +1231,19 @@ 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
merge!(layout, Dict(x, "x"))
end
end

if pl.yaxis !== nothing
for d in Dict.(pl.yaxis)
for y in pl.yaxis
merge!(layout, Dict(y, "y"))
end
end

if pl.axes !== nothing
for d in Dict.(pl.axes)
merge!(layout, d)
end
end
Expand Down
Loading