From be4a3741224afc04d64c805a845d762ca64f2a69 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 20 Aug 2017 21:55:21 +0200 Subject: [PATCH] allow turning on/off the axes border --- src/arg_desc.jl | 1 + src/args.jl | 2 ++ src/axes.jl | 8 ++++---- src/backends/glvisualize.jl | 3 ++- src/backends/gr.jl | 1 + src/backends/pyplot.jl | 7 +++++++ 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/arg_desc.jl b/src/arg_desc.jl index ee1e99d8..f3b56493 100644 --- a/src/arg_desc.jl +++ b/src/arg_desc.jl @@ -93,6 +93,7 @@ const _arg_desc = KW( :bottom_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding on the bottom of the subplot.", :subplot_index => "Integer. Internal (not set by user). Specifies the index of this subplot in the Plot's `plt.subplot` list.", :colorbar_title => "String. Title of colorbar.", +:draw_axes_border => "Bool. Draw a border around the axes.", # axis args :guide => "String. Axis guide (label).", diff --git a/src/args.jl b/src/args.jl index 37dd250e..4665f964 100644 --- a/src/args.jl +++ b/src/args.jl @@ -282,6 +282,7 @@ const _subplot_defaults = KW( :bottom_margin => :match, :subplot_index => -1, :colorbar_title => "", + :draw_axes_border => false, ) const _axis_defaults = KW( @@ -493,6 +494,7 @@ add_aliases(:orientation, :direction, :dir) add_aliases(:inset_subplots, :inset, :floating) add_aliases(:gridlinewidth, :gridwidth, :grid_linewidth, :grid_width, :gridlw, :grid_lw) add_aliases(:gridstyle, :grid_style, :gridlinestyle, :grid_linestyle, :grid_ls, :gridls) +add_aliases(:draw_axes_border, :axes_border, :show_axes_border) # add all pluralized forms to the _keyAliases dict diff --git a/src/axes.jl b/src/axes.jl index 734f2154..22c868ff 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -502,10 +502,10 @@ function axis_drawing_info(sp::Subplot) t2 = invf(f(ymax) - 0.015*(f(ymax)-f(ymin))) push!(xspine_segs, (xmin,ymin), (xmax,ymin)) # bottom spine - # push!(xspine_segs, (xmin,ymax), (xmax,ymax)) # top spine + sp[:draw_axes_border] && push!(xspine_segs, (xmin,ymax), (xmax,ymax)) # top spine for xtick in xticks[1] push!(xspine_segs, (xtick, ymin), (xtick, t1)) # bottom tick - # push!(xspine_segs, (xtick, ymax), (xtick, t2)) # top tick + # sp[:draw_axes_border] && push!(xspine_segs, (xtick, ymax), (xtick, t2)) # top tick xaxis[:grid] && push!(xgrid_segs, (xtick, t1), (xtick, t2)) # vertical grid end end @@ -517,10 +517,10 @@ function axis_drawing_info(sp::Subplot) t2 = invf(f(xmax) - 0.015*(f(xmax)-f(xmin))) push!(yspine_segs, (xmin,ymin), (xmin,ymax)) # left spine - # push!(yspine_segs, (xmax,ymin), (xmax,ymax)) # right spine + sp[:draw_axes_border] && push!(yspine_segs, (xmax,ymin), (xmax,ymax)) # right spine for ytick in yticks[1] push!(yspine_segs, (xmin, ytick), (t1, ytick)) # left tick - # push!(yspine_segs, (xmax, ytick), (t2, ytick)) # right tick + # sp[:draw_axes_border] && push!(yspine_segs, (xmax, ytick), (t2, ytick)) # right tick yaxis[:grid] && push!(ygrid_segs, (t1, ytick), (t2, ytick)) # horizontal grid end end diff --git a/src/backends/glvisualize.jl b/src/backends/glvisualize.jl index 60c1730a..91deb56c 100644 --- a/src/backends/glvisualize.jl +++ b/src/backends/glvisualize.jl @@ -39,7 +39,8 @@ const _glvisualize_attr = merge_with_base_supported([ :clims, :inset_subplots, :dpi, - :hover + :hover, + :draw_axes_border, ]) const _glvisualize_seriestype = [ :path, :shape, diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 3622402b..0c01b8f4 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -32,6 +32,7 @@ const _gr_attr = merge_with_base_supported([ :inset_subplots, :bar_width, :arrow, + :draw_axes_border, ]) const _gr_seriestype = [ :path, :scatter, diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 4b185e6e..ea143e1e 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -32,6 +32,7 @@ const _pyplot_attr = merge_with_base_supported([ :inset_subplots, :dpi, :colorbar_title, + :draw_axes_border, ]) const _pyplot_seriestype = [ :path, :steppre, :steppost, :shape, @@ -1088,6 +1089,12 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) # this sets the bg color inside the grid ax[set_facecolor_sym](py_color(sp[:background_color_inside])) + + if !sp[:draw_axes_border] + # hide the right and top spines + ax[:spines]["right"][:set_visible](false) + ax[:spines]["top"][:set_visible](false) + end end py_drawfig(fig) end