diff --git a/src/args.jl b/src/args.jl index 6afdd66b..500d0e68 100644 --- a/src/args.jl +++ b/src/args.jl @@ -181,13 +181,14 @@ function hasgrid(arg::Symbol, letter) end hasgrid(arg::AbstractString, letter) = hasgrid(Symbol(arg), letter) -const _allFramestyles = [:box, :semi, :axes, :grid, :none] +const _allFramestyles = [:box, :semi, :axes, :origin, :grid, :none] const _framestyleAliases = Dict{Symbol, Symbol}( :frame => :box, :border => :box, :on => :box, :transparent => :semi, :semitransparent => :semi, + :zeroline => :origin, ) # ----------------------------------------------------------------------------- diff --git a/src/axes.jl b/src/axes.jl index 850b67cb..58134c29 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -515,7 +515,8 @@ function axis_drawing_info(sp::Subplot) if !(sp[:framestyle] == :none) # xaxis - sp[:framestyle] == :grid || push!(xaxis_segs, (xmin,ymin), (xmax,ymin)) # bottom spine / xaxis + sp[:framestyle] in (:grid, :origin) || push!(xaxis_segs, (xmin,ymin), (xmax,ymin)) # bottom spine / xaxis + sp[:framestyle] == :origin && push!(xaxis_segs, (xmin, 0.0), (xmax, 0.0)) sp[:framestyle] in (:semi, :box) && push!(xborder_segs, (xmin,ymax), (xmax,ymax)) # top spine if !(xaxis[:ticks] in (nothing, false)) f = scalefunc(yaxis[:scale]) @@ -531,7 +532,8 @@ function axis_drawing_info(sp::Subplot) end # yaxis - sp[:framestyle] == :grid || push!(yaxis_segs, (xmin,ymin), (xmin,ymax)) # left spine / yaxis + sp[:framestyle] in (:grid, :origin) || push!(yaxis_segs, (xmin,ymin), (xmin,ymax)) # left spine / yaxis + sp[:framestyle] == :origin && push!(yaxis_segs, (0.0, ymin), (0.0, ymax)) sp[:framestyle] in (:semi, :box) && push!(yborder_segs, (xmax,ymin), (xmax,ymax)) # right spine if !(yaxis[:ticks] in (nothing, false)) f = scalefunc(xaxis[:scale]) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 80a7f77c..72cc0ebd 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1099,9 +1099,13 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) ax[:spines]["top"][:set_alpha](intensity) ax[:spines]["right"][:set_linewidth](intensity) ax[:spines]["top"][:set_linewidth](intensity) - elseif sp[:framestyle] == :axes + elseif sp[:framestyle] in (:axes, :origin) ax[:spines]["right"][:set_visible](false) ax[:spines]["top"][:set_visible](false) + if sp[:framestyle] == :origin + ax[:spines]["left"][:set_position]("zero") + ax[:spines]["bottom"][:set_position]("zero") + end elseif sp[:framestyle] in (:grid, :none) for (loc, spine) in ax[:spines] spine[:set_visible](false) diff --git a/src/pipeline.jl b/src/pipeline.jl index e0041b77..47c25abb 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -364,6 +364,11 @@ function _expand_subplot_extrema(sp::Subplot, d::KW, st::Symbol) elseif !(st in (:pie, :histogram, :bins2d, :histogram2d)) expand_extrema!(sp, d) end + # expand for zerolines (axes through origin) + if sp[:framestyle] == :origin + expand_extrema!(sp[:xaxis], 0.0) + expand_extrema!(sp[:yaxis], 0.0) + end end function _add_the_series(plt, sp, d)