added mirror and implemented in pyplot
This commit is contained in:
parent
8d7c4cd108
commit
f63eac9a73
@ -107,5 +107,6 @@ const _arg_desc = KW(
|
||||
:foreground_color_border => "Color Type or `:match` (matches `:foreground_color_subplot`). Color of plot area border (spines).",
|
||||
:foreground_color_text => "Color Type or `:match` (matches `:foreground_color_subplot`). Color of tick labels.",
|
||||
:foreground_color_guide => "Color Type or `:match` (matches `:foreground_color_subplot`). Color of axis guides (axis labels).",
|
||||
:mirror => "Bool. Switch the side of the tick labels (right or top).",
|
||||
|
||||
)
|
||||
|
||||
36
src/args.jl
36
src/args.jl
@ -266,6 +266,7 @@ const _axis_defaults = KW(
|
||||
:foreground_color_guide => :match, # guide text color,
|
||||
:discrete_values => [],
|
||||
:formatter => :auto,
|
||||
:mirror => true,
|
||||
)
|
||||
|
||||
const _suppress_warnings = Set{Symbol}([
|
||||
@ -285,23 +286,24 @@ const _suppress_warnings = Set{Symbol}([
|
||||
# add defaults for the letter versions
|
||||
const _axis_defaults_byletter = KW()
|
||||
for letter in (:x,:y,:z)
|
||||
for k in (
|
||||
:guide,
|
||||
:lims,
|
||||
:ticks,
|
||||
:scale,
|
||||
:rotation,
|
||||
:flip,
|
||||
:link,
|
||||
:tickfont,
|
||||
:guidefont,
|
||||
:foreground_color_axis,
|
||||
:foreground_color_border,
|
||||
:foreground_color_text,
|
||||
:foreground_color_guide,
|
||||
:discrete_values,
|
||||
:formatter,
|
||||
)
|
||||
for k in keys(_axis_defaults)
|
||||
# for k in (
|
||||
# :guide,
|
||||
# :lims,
|
||||
# :ticks,
|
||||
# :scale,
|
||||
# :rotation,
|
||||
# :flip,
|
||||
# :link,
|
||||
# :tickfont,
|
||||
# :guidefont,
|
||||
# :foreground_color_axis,
|
||||
# :foreground_color_border,
|
||||
# :foreground_color_text,
|
||||
# :foreground_color_guide,
|
||||
# :discrete_values,
|
||||
# :formatter,
|
||||
# )
|
||||
_axis_defaults_byletter[Symbol(letter,k)] = :match
|
||||
|
||||
# allow the underscore version too: xguide or x_guide
|
||||
|
||||
@ -985,8 +985,15 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
||||
# axis attributes
|
||||
for letter in (:x, :y, :z)
|
||||
axissym = Symbol(letter, :axis)
|
||||
axis = sp[axissym]
|
||||
haskey(ax, axissym) || continue
|
||||
axis = sp[axissym]
|
||||
pyaxis = ax[axissym]
|
||||
if axis[:mirror] && letter != :z
|
||||
pos = letter == :x ? "top" : "right"
|
||||
pyaxis[:set_label_position](pos) # the guides
|
||||
pyaxis[:set_ticks_position]("both") # the hash marks
|
||||
pyaxis[Symbol(:tick_, pos)]() # the tick labels
|
||||
end
|
||||
py_set_scale(ax, axis)
|
||||
py_set_lims(ax, axis)
|
||||
py_set_ticks(ax, get_ticks(axis), letter)
|
||||
@ -994,14 +1001,14 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
||||
if get(axis.d, :flip, false)
|
||||
ax[Symbol("invert_", letter, "axis")]()
|
||||
end
|
||||
ax[axissym][:label][:set_fontsize](py_dpi_scale(plt, axis[:guidefont].pointsize))
|
||||
pyaxis[:label][:set_fontsize](py_dpi_scale(plt, axis[:guidefont].pointsize))
|
||||
for lab in ax[Symbol("get_", letter, "ticklabels")]()
|
||||
lab[:set_fontsize](py_dpi_scale(plt, axis[:tickfont].pointsize))
|
||||
lab[:set_rotation](axis[:rotation])
|
||||
end
|
||||
if sp[:grid]
|
||||
fgcolor = py_color(sp[:foreground_color_grid])
|
||||
ax[axissym][:grid](true, color = fgcolor)
|
||||
pyaxis[:grid](true, color = fgcolor)
|
||||
ax[:set_axisbelow](true)
|
||||
end
|
||||
py_set_axis_colors(ax, axis)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user