From 3fd745a5df33e913bbce93f184f78bcdfc776af5 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Wed, 30 Aug 2017 23:42:57 +0200 Subject: [PATCH] remove 0 tick label --- src/args.jl | 1 + src/axes.jl | 16 ++++++++++++++-- src/backends/pyplot.jl | 4 ++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/args.jl b/src/args.jl index 500d0e68..5e9675c3 100644 --- a/src/args.jl +++ b/src/args.jl @@ -189,6 +189,7 @@ const _framestyleAliases = Dict{Symbol, Symbol}( :transparent => :semi, :semitransparent => :semi, :zeroline => :origin, + :zero => :origin, ) # ----------------------------------------------------------------------------- diff --git a/src/axes.jl b/src/axes.jl index 6d321594..db4e88fa 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -516,7 +516,13 @@ function axis_drawing_info(sp::Subplot) if !(sp[:framestyle] == :none) # 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 if !(xaxis[:ticks] in (nothing, false)) f = scalefunc(yaxis[:scale]) @@ -539,7 +545,13 @@ function axis_drawing_info(sp::Subplot) # 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 if !(yaxis[:ticks] in (nothing, false)) f = scalefunc(xaxis[:scale]) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 5c40f284..225987f7 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1077,6 +1077,10 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) py_set_scale(ax, axis) py_set_lims(ax, 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) ax[Symbol("set_", letter, "label")](axis[:guide]) if get(axis.d, :flip, false)