remove 0 tick label

This commit is contained in:
Daniel Schwabeneder 2017-08-30 23:42:57 +02:00
parent 5e968e0aa8
commit 3fd745a5df
3 changed files with 19 additions and 2 deletions

View File

@ -189,6 +189,7 @@ const _framestyleAliases = Dict{Symbol, Symbol}(
:transparent => :semi, :transparent => :semi,
:semitransparent => :semi, :semitransparent => :semi,
:zeroline => :origin, :zeroline => :origin,
:zero => :origin,
) )
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------

View File

@ -516,7 +516,13 @@ function axis_drawing_info(sp::Subplot)
if !(sp[:framestyle] == :none) if !(sp[:framestyle] == :none)
# xaxis # xaxis
sp[:framestyle] in (:grid, :origin) || 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)) if sp[:framestyle] == :origin
push!(xaxis_segs, (xmin, 0.0), (xmax, 0.0))
# don't show the 0 tick label for the origin framestyle
if length(yticks) > 1
xticks[2][xticks[1] .== 0] = ""
end
end
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])
@ -539,7 +545,13 @@ function axis_drawing_info(sp::Subplot)
# yaxis # yaxis
sp[:framestyle] in (:grid, :origin) || 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)) if sp[:framestyle] == :origin
push!(yaxis_segs, (0.0, ymin), (0.0, ymax))
# don't show the 0 tick label for the origin framestyle
if length(yticks) > 1
yticks[2][yticks[1] .== 0] = ""
end
end
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

@ -1077,6 +1077,10 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
py_set_scale(ax, axis) py_set_scale(ax, axis)
py_set_lims(ax, axis) py_set_lims(ax, axis)
ticks = sp[:framestyle] == :none ? nothing : get_ticks(axis) ticks = sp[:framestyle] == :none ? nothing : get_ticks(axis)
# don't show the 0 tick label for the origin framestyle
if sp[:framestyle] == :origin && length(ticks) > 1
ticks[2][ticks[1] .== 0] = ""
end
py_set_ticks(ax, ticks, letter) py_set_ticks(ax, ticks, letter)
ax[Symbol("set_", letter, "label")](axis[:guide]) ax[Symbol("set_", letter, "label")](axis[:guide])
if get(axis.d, :flip, false) if get(axis.d, :flip, false)