allow turning on/off the axes border

This commit is contained in:
Daniel Schwabeneder 2017-08-20 21:55:21 +02:00
parent 5945196a4f
commit be4a374122
6 changed files with 17 additions and 5 deletions

View File

@ -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).",

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -32,6 +32,7 @@ const _gr_attr = merge_with_base_supported([
:inset_subplots,
:bar_width,
:arrow,
:draw_axes_border,
])
const _gr_seriestype = [
:path, :scatter,

View File

@ -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