add origin framestyle

This commit is contained in:
Daniel Schwabeneder 2017-08-29 20:36:59 +02:00
parent de32b02c75
commit 41877e362a
4 changed files with 16 additions and 4 deletions

View File

@ -181,13 +181,14 @@ function hasgrid(arg::Symbol, letter)
end end
hasgrid(arg::AbstractString, letter) = hasgrid(Symbol(arg), letter) 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}( const _framestyleAliases = Dict{Symbol, Symbol}(
:frame => :box, :frame => :box,
:border => :box, :border => :box,
:on => :box, :on => :box,
:transparent => :semi, :transparent => :semi,
:semitransparent => :semi, :semitransparent => :semi,
:zeroline => :origin,
) )
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------

View File

@ -515,7 +515,8 @@ function axis_drawing_info(sp::Subplot)
if !(sp[:framestyle] == :none) if !(sp[:framestyle] == :none)
# xaxis # 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 sp[:framestyle] in (:semi, :box) && push!(xborder_segs, (xmin,ymax), (xmax,ymax)) # top spine
if !(xaxis[:ticks] in (nothing, false)) if !(xaxis[:ticks] in (nothing, false))
f = scalefunc(yaxis[:scale]) f = scalefunc(yaxis[:scale])
@ -531,7 +532,8 @@ function axis_drawing_info(sp::Subplot)
end end
# yaxis # 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 sp[:framestyle] in (:semi, :box) && push!(yborder_segs, (xmax,ymin), (xmax,ymax)) # right spine
if !(yaxis[:ticks] in (nothing, false)) if !(yaxis[:ticks] in (nothing, false))
f = scalefunc(xaxis[:scale]) f = scalefunc(xaxis[:scale])

View File

@ -1099,9 +1099,13 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
ax[:spines]["top"][:set_alpha](intensity) ax[:spines]["top"][:set_alpha](intensity)
ax[:spines]["right"][:set_linewidth](intensity) ax[:spines]["right"][:set_linewidth](intensity)
ax[:spines]["top"][: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]["right"][:set_visible](false)
ax[:spines]["top"][: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) elseif sp[:framestyle] in (:grid, :none)
for (loc, spine) in ax[:spines] for (loc, spine) in ax[:spines]
spine[:set_visible](false) spine[:set_visible](false)

View File

@ -364,6 +364,11 @@ function _expand_subplot_extrema(sp::Subplot, d::KW, st::Symbol)
elseif !(st in (:pie, :histogram, :bins2d, :histogram2d)) elseif !(st in (:pie, :histogram, :bins2d, :histogram2d))
expand_extrema!(sp, d) expand_extrema!(sp, d)
end 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 end
function _add_the_series(plt, sp, d) function _add_the_series(plt, sp, d)