Generalized axis symbol lookup elsewhere
This commit is contained in:
parent
0809c21490
commit
274fdd11a4
84
src/args.jl
84
src/args.jl
@ -276,7 +276,7 @@ function hasgrid(arg::Symbol, letter)
|
|||||||
arg in (:all, :both, :on) || occursin(string(letter), string(arg))
|
arg in (:all, :both, :on) || occursin(string(letter), string(arg))
|
||||||
else
|
else
|
||||||
@warn(
|
@warn(
|
||||||
"Unknown grid argument $arg; $(Symbol(letter, :grid)) was set to `true` instead."
|
"Unknown grid argument $arg; $(get_axis_attr(letter, :grid)) was set to `true` instead."
|
||||||
)
|
)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
@ -316,7 +316,7 @@ function showaxis(arg::Symbol, letter)
|
|||||||
arg in (:all, :both, :on, :yes) || occursin(string(letter), string(arg))
|
arg in (:all, :both, :on, :yes) || occursin(string(letter), string(arg))
|
||||||
else
|
else
|
||||||
@warn(
|
@warn(
|
||||||
"Unknown showaxis argument $arg; $(Symbol(letter, :showaxis)) was set to `true` instead."
|
"Unknown showaxis argument $arg; $(get_axis_attr(letter, :showaxis)) was set to `true` instead."
|
||||||
)
|
)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
@ -573,7 +573,7 @@ reset_axis_defaults_byletter!()
|
|||||||
|
|
||||||
for letter in (:x, :y, :z), k in keys(_axis_defaults)
|
for letter in (:x, :y, :z), k in keys(_axis_defaults)
|
||||||
# allow the underscore version too: xguide or x_guide
|
# allow the underscore version too: xguide or x_guide
|
||||||
add_aliases(Symbol(letter, k), Symbol(letter, "_", k))
|
add_aliases(get_axis_attr(letter, k), get_axis_attr(letter, "_", k))
|
||||||
end
|
end
|
||||||
|
|
||||||
const _all_defaults = KW[_series_defaults, _plot_defaults, _subplot_defaults]
|
const _all_defaults = KW[_series_defaults, _plot_defaults, _subplot_defaults]
|
||||||
@ -1004,7 +1004,7 @@ function parse_axis_kw(s::Symbol)
|
|||||||
s = string(s)
|
s = string(s)
|
||||||
for letter in ('x', 'y', 'z')
|
for letter in ('x', 'y', 'z')
|
||||||
if startswith(s, letter)
|
if startswith(s, letter)
|
||||||
return (Symbol(letter), Symbol(chop(s, head = 1, tail = 0)))
|
return (get_axis_attr(letter), Symbol(chop(s, head = 1, tail = 0)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nothing
|
return nothing
|
||||||
@ -1216,69 +1216,69 @@ end
|
|||||||
|
|
||||||
function processGridArg!(plotattributes::AKW, arg, letter)
|
function processGridArg!(plotattributes::AKW, arg, letter)
|
||||||
if arg in _allGridArgs || isa(arg, Bool)
|
if arg in _allGridArgs || isa(arg, Bool)
|
||||||
plotattributes[Symbol(letter, :grid)] = hasgrid(arg, letter)
|
plotattributes[get_axis_attr(letter, :grid)] = hasgrid(arg, letter)
|
||||||
|
|
||||||
elseif allStyles(arg)
|
elseif allStyles(arg)
|
||||||
plotattributes[Symbol(letter, :gridstyle)] = arg
|
plotattributes[get_axis_attr(letter, :gridstyle)] = arg
|
||||||
|
|
||||||
elseif typeof(arg) <: Stroke
|
elseif typeof(arg) <: Stroke
|
||||||
arg.width === nothing ||
|
arg.width === nothing ||
|
||||||
(plotattributes[Symbol(letter, :gridlinewidth)] = arg.width)
|
(plotattributes[get_axis_attr(letter, :gridlinewidth)] = arg.width)
|
||||||
arg.color === nothing || (
|
arg.color === nothing || (
|
||||||
plotattributes[Symbol(letter, :foreground_color_grid)] =
|
plotattributes[get_axis_attr(letter, :foreground_color_grid)] =
|
||||||
arg.color in (:auto, :match) ? :match : plot_color(arg.color)
|
arg.color in (:auto, :match) ? :match : plot_color(arg.color)
|
||||||
)
|
)
|
||||||
arg.alpha === nothing || (plotattributes[Symbol(letter, :gridalpha)] = arg.alpha)
|
arg.alpha === nothing || (plotattributes[get_axis_attr(letter, :gridalpha)] = arg.alpha)
|
||||||
arg.style === nothing || (plotattributes[Symbol(letter, :gridstyle)] = arg.style)
|
arg.style === nothing || (plotattributes[get_axis_attr(letter, :gridstyle)] = arg.style)
|
||||||
|
|
||||||
# linealpha
|
# linealpha
|
||||||
elseif allAlphas(arg)
|
elseif allAlphas(arg)
|
||||||
plotattributes[Symbol(letter, :gridalpha)] = arg
|
plotattributes[get_axis_attr(letter, :gridalpha)] = arg
|
||||||
|
|
||||||
# linewidth
|
# linewidth
|
||||||
elseif allReals(arg)
|
elseif allReals(arg)
|
||||||
plotattributes[Symbol(letter, :gridlinewidth)] = arg
|
plotattributes[get_axis_attr(letter, :gridlinewidth)] = arg
|
||||||
|
|
||||||
# color
|
# color
|
||||||
elseif !handleColors!(plotattributes, arg, Symbol(letter, :foreground_color_grid))
|
elseif !handleColors!(plotattributes, arg, get_axis_attr(letter, :foreground_color_grid))
|
||||||
@warn("Skipped grid arg $arg.")
|
@warn("Skipped grid arg $arg.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function processMinorGridArg!(plotattributes::AKW, arg, letter)
|
function processMinorGridArg!(plotattributes::AKW, arg, letter)
|
||||||
if arg in _allGridArgs || isa(arg, Bool)
|
if arg in _allGridArgs || isa(arg, Bool)
|
||||||
plotattributes[Symbol(letter, :minorgrid)] = hasgrid(arg, letter)
|
plotattributes[get_axis_attr(letter, :minorgrid)] = hasgrid(arg, letter)
|
||||||
|
|
||||||
elseif allStyles(arg)
|
elseif allStyles(arg)
|
||||||
plotattributes[Symbol(letter, :minorgridstyle)] = arg
|
plotattributes[get_axis_attr(letter, :minorgridstyle)] = arg
|
||||||
plotattributes[Symbol(letter, :minorgrid)] = true
|
plotattributes[get_axis_attr(letter, :minorgrid)] = true
|
||||||
|
|
||||||
elseif typeof(arg) <: Stroke
|
elseif typeof(arg) <: Stroke
|
||||||
arg.width === nothing ||
|
arg.width === nothing ||
|
||||||
(plotattributes[Symbol(letter, :minorgridlinewidth)] = arg.width)
|
(plotattributes[get_axis_attr(letter, :minorgridlinewidth)] = arg.width)
|
||||||
arg.color === nothing || (
|
arg.color === nothing || (
|
||||||
plotattributes[Symbol(letter, :foreground_color_minor_grid)] =
|
plotattributes[get_axis_attr(letter, :foreground_color_minor_grid)] =
|
||||||
arg.color in (:auto, :match) ? :match : plot_color(arg.color)
|
arg.color in (:auto, :match) ? :match : plot_color(arg.color)
|
||||||
)
|
)
|
||||||
arg.alpha === nothing ||
|
arg.alpha === nothing ||
|
||||||
(plotattributes[Symbol(letter, :minorgridalpha)] = arg.alpha)
|
(plotattributes[get_axis_attr(letter, :minorgridalpha)] = arg.alpha)
|
||||||
arg.style === nothing ||
|
arg.style === nothing ||
|
||||||
(plotattributes[Symbol(letter, :minorgridstyle)] = arg.style)
|
(plotattributes[get_axis_attr(letter, :minorgridstyle)] = arg.style)
|
||||||
plotattributes[Symbol(letter, :minorgrid)] = true
|
plotattributes[get_axis_attr(letter, :minorgrid)] = true
|
||||||
|
|
||||||
# linealpha
|
# linealpha
|
||||||
elseif allAlphas(arg)
|
elseif allAlphas(arg)
|
||||||
plotattributes[Symbol(letter, :minorgridalpha)] = arg
|
plotattributes[get_axis_attr(letter, :minorgridalpha)] = arg
|
||||||
plotattributes[Symbol(letter, :minorgrid)] = true
|
plotattributes[get_axis_attr(letter, :minorgrid)] = true
|
||||||
|
|
||||||
# linewidth
|
# linewidth
|
||||||
elseif allReals(arg)
|
elseif allReals(arg)
|
||||||
plotattributes[Symbol(letter, :minorgridlinewidth)] = arg
|
plotattributes[get_axis_attr(letter, :minorgridlinewidth)] = arg
|
||||||
plotattributes[Symbol(letter, :minorgrid)] = true
|
plotattributes[get_axis_attr(letter, :minorgrid)] = true
|
||||||
|
|
||||||
# color
|
# color
|
||||||
elseif handleColors!(plotattributes, arg, Symbol(letter, :foreground_color_minor_grid))
|
elseif handleColors!(plotattributes, arg, get_axis_attr(letter, :foreground_color_minor_grid))
|
||||||
plotattributes[Symbol(letter, :minorgrid)] = true
|
plotattributes[get_axis_attr(letter, :minorgrid)] = true
|
||||||
else
|
else
|
||||||
@warn("Skipped grid arg $arg.")
|
@warn("Skipped grid arg $arg.")
|
||||||
end
|
end
|
||||||
@ -1344,7 +1344,7 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW)
|
|||||||
end
|
end
|
||||||
# handle axis args
|
# handle axis args
|
||||||
for letter in (:x, :y, :z)
|
for letter in (:x, :y, :z)
|
||||||
asym = Symbol(letter, :axis)
|
asym = get_axis_attr(letter, :axis)
|
||||||
args = RecipesPipeline.pop_kw!(plotattributes, asym, ())
|
args = RecipesPipeline.pop_kw!(plotattributes, asym, ())
|
||||||
if !(typeof(args) <: Axis)
|
if !(typeof(args) <: Axis)
|
||||||
for arg in wraptuple(args)
|
for arg in wraptuple(args)
|
||||||
@ -1371,7 +1371,7 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW)
|
|||||||
end
|
end
|
||||||
# handle individual axes grid args
|
# handle individual axes grid args
|
||||||
for letter in (:x, :y, :z)
|
for letter in (:x, :y, :z)
|
||||||
gridsym = Symbol(letter, :grid)
|
gridsym = get_axis_attr(letter, :grid)
|
||||||
args = RecipesPipeline.pop_kw!(plotattributes, gridsym, ())
|
args = RecipesPipeline.pop_kw!(plotattributes, gridsym, ())
|
||||||
for arg in wraptuple(args)
|
for arg in wraptuple(args)
|
||||||
processGridArg!(plotattributes, arg, letter)
|
processGridArg!(plotattributes, arg, letter)
|
||||||
@ -1386,7 +1386,7 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW)
|
|||||||
end
|
end
|
||||||
# handle individual axes grid args
|
# handle individual axes grid args
|
||||||
for letter in (:x, :y, :z)
|
for letter in (:x, :y, :z)
|
||||||
gridsym = Symbol(letter, :minorgrid)
|
gridsym = get_axis_attr(letter, :minorgrid)
|
||||||
args = RecipesPipeline.pop_kw!(plotattributes, gridsym, ())
|
args = RecipesPipeline.pop_kw!(plotattributes, gridsym, ())
|
||||||
for arg in wraptuple(args)
|
for arg in wraptuple(args)
|
||||||
processMinorGridArg!(plotattributes, arg, letter)
|
processMinorGridArg!(plotattributes, arg, letter)
|
||||||
@ -1397,16 +1397,16 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW)
|
|||||||
args = RecipesPipeline.pop_kw!(plotattributes, fontname, ())
|
args = RecipesPipeline.pop_kw!(plotattributes, fontname, ())
|
||||||
for arg in wraptuple(args)
|
for arg in wraptuple(args)
|
||||||
for letter in (:x, :y, :z)
|
for letter in (:x, :y, :z)
|
||||||
processFontArg!(plotattributes, Symbol(letter, fontname), arg)
|
processFontArg!(plotattributes, get_axis_attr(letter, fontname), arg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# handle individual axes font args
|
# handle individual axes font args
|
||||||
for letter in (:x, :y, :z)
|
for letter in (:x, :y, :z)
|
||||||
for fontname in (:tickfont, :guidefont)
|
for fontname in (:tickfont, :guidefont)
|
||||||
args = RecipesPipeline.pop_kw!(plotattributes, Symbol(letter, fontname), ())
|
args = RecipesPipeline.pop_kw!(plotattributes, get_axis_attr(letter, fontname), ())
|
||||||
for arg in wraptuple(args)
|
for arg in wraptuple(args)
|
||||||
processFontArg!(plotattributes, Symbol(letter, fontname), arg)
|
processFontArg!(plotattributes, get_axis_attr(letter, fontname), arg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1415,7 +1415,7 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW)
|
|||||||
if haskey(plotattributes, k) && k !== :link
|
if haskey(plotattributes, k) && k !== :link
|
||||||
v = plotattributes[k]
|
v = plotattributes[k]
|
||||||
for letter in (:x, :y, :z)
|
for letter in (:x, :y, :z)
|
||||||
lk = Symbol(letter, k)
|
lk = get_axis_attr(letter, k)
|
||||||
if !is_explicit(plotattributes, lk)
|
if !is_explicit(plotattributes, lk)
|
||||||
plotattributes[lk] = v
|
plotattributes[lk] = v
|
||||||
end
|
end
|
||||||
@ -1905,8 +1905,6 @@ function _update_axis(
|
|||||||
_update_axis_links(plt, axis, letter)
|
_update_axis_links(plt, axis, letter)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
axisattrcache = Dict{Symbol, Dict{Symbol, Symbol}}()
|
|
||||||
|
|
||||||
function _update_axis(
|
function _update_axis(
|
||||||
axis::Axis,
|
axis::Axis,
|
||||||
@ -1924,17 +1922,7 @@ function _update_axis(
|
|||||||
end
|
end
|
||||||
|
|
||||||
# then get those args that were passed with a leading letter: `xlabel = "X"`
|
# then get those args that were passed with a leading letter: `xlabel = "X"`
|
||||||
lt = if haskey(axisattrcache, letter)
|
lk = get_axis_attr(letter, k)
|
||||||
axisattrcache[letter]
|
|
||||||
else
|
|
||||||
axisattrcache[letter] = Dict{Symbol, Symbol}()
|
|
||||||
end
|
|
||||||
|
|
||||||
lk = if haskey(lt, k)
|
|
||||||
lt[k]
|
|
||||||
else
|
|
||||||
lt[k] = Symbol(letter, k)
|
|
||||||
end
|
|
||||||
|
|
||||||
if haskey(plotattributes_in, lk)
|
if haskey(plotattributes_in, lk)
|
||||||
kw[k] = slice_arg(plotattributes_in[lk], subplot_index)
|
kw[k] = slice_arg(plotattributes_in[lk], subplot_index)
|
||||||
@ -1992,7 +1980,7 @@ function _update_subplot_args(
|
|||||||
lims_warned = false
|
lims_warned = false
|
||||||
for letter in (:x, :y, :z)
|
for letter in (:x, :y, :z)
|
||||||
_update_axis(plt, sp, plotattributes_in, letter, subplot_index)
|
_update_axis(plt, sp, plotattributes_in, letter, subplot_index)
|
||||||
lk = Symbol(letter, :lims)
|
lk = get_axis_attr(letter, :lims)
|
||||||
|
|
||||||
# warn against using `Range` in x,y,z lims
|
# warn against using `Range` in x,y,z lims
|
||||||
if !lims_warned &&
|
if !lims_warned &&
|
||||||
|
|||||||
42
src/axes.jl
42
src/axes.jl
@ -23,7 +23,7 @@ function Axis(sp::Subplot, letter::Symbol, args...; kw...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function get_axis(sp::Subplot, letter::Symbol)
|
function get_axis(sp::Subplot, letter::Symbol)
|
||||||
axissym = Symbol(letter, :axis)
|
axissym = get_axis_attr(letter, :axis)
|
||||||
if haskey(sp.attr, axissym)
|
if haskey(sp.attr, axissym)
|
||||||
sp.attr[axissym]
|
sp.attr[axissym]
|
||||||
else
|
else
|
||||||
@ -35,40 +35,40 @@ function process_axis_arg!(plotattributes::AKW, arg, letter = "")
|
|||||||
T = typeof(arg)
|
T = typeof(arg)
|
||||||
arg = get(_scaleAliases, arg, arg)
|
arg = get(_scaleAliases, arg, arg)
|
||||||
if typeof(arg) <: Font
|
if typeof(arg) <: Font
|
||||||
plotattributes[Symbol(letter, :tickfont)] = arg
|
plotattributes[get_axis_attr(letter, :tickfont)] = arg
|
||||||
plotattributes[Symbol(letter, :guidefont)] = arg
|
plotattributes[get_axis_attr(letter, :guidefont)] = arg
|
||||||
|
|
||||||
elseif arg in _allScales
|
elseif arg in _allScales
|
||||||
plotattributes[Symbol(letter, :scale)] = arg
|
plotattributes[get_axis_attr(letter, :scale)] = arg
|
||||||
|
|
||||||
elseif arg in (:flip, :invert, :inverted)
|
elseif arg in (:flip, :invert, :inverted)
|
||||||
plotattributes[Symbol(letter, :flip)] = true
|
plotattributes[get_axis_attr(letter, :flip)] = true
|
||||||
|
|
||||||
elseif T <: AbstractString
|
elseif T <: AbstractString
|
||||||
plotattributes[Symbol(letter, :guide)] = arg
|
plotattributes[get_axis_attr(letter, :guide)] = arg
|
||||||
|
|
||||||
# xlims/ylims
|
# xlims/ylims
|
||||||
elseif (T <: Tuple || T <: AVec) && length(arg) == 2
|
elseif (T <: Tuple || T <: AVec) && length(arg) == 2
|
||||||
sym = typeof(arg[1]) <: Number ? :lims : :ticks
|
sym = typeof(arg[1]) <: Number ? :lims : :ticks
|
||||||
plotattributes[Symbol(letter, sym)] = arg
|
plotattributes[get_axis_attr(letter, sym)] = arg
|
||||||
|
|
||||||
# xticks/yticks
|
# xticks/yticks
|
||||||
elseif T <: AVec
|
elseif T <: AVec
|
||||||
plotattributes[Symbol(letter, :ticks)] = arg
|
plotattributes[get_axis_attr(letter, :ticks)] = arg
|
||||||
|
|
||||||
elseif arg === nothing
|
elseif arg === nothing
|
||||||
plotattributes[Symbol(letter, :ticks)] = []
|
plotattributes[get_axis_attr(letter, :ticks)] = []
|
||||||
|
|
||||||
elseif T <: Bool || arg in _allShowaxisArgs
|
elseif T <: Bool || arg in _allShowaxisArgs
|
||||||
plotattributes[Symbol(letter, :showaxis)] = showaxis(arg, letter)
|
plotattributes[get_axis_attr(letter, :showaxis)] = showaxis(arg, letter)
|
||||||
|
|
||||||
elseif typeof(arg) <: Number
|
elseif typeof(arg) <: Number
|
||||||
plotattributes[Symbol(letter, :rotation)] = arg
|
plotattributes[get_axis_attr(letter, :rotation)] = arg
|
||||||
|
|
||||||
elseif typeof(arg) <: Function
|
elseif typeof(arg) <: Function
|
||||||
plotattributes[Symbol(letter, :formatter)] = arg
|
plotattributes[get_axis_attr(letter, :formatter)] = arg
|
||||||
|
|
||||||
elseif !handleColors!(plotattributes, arg, Symbol(letter, :foreground_color_axis))
|
elseif !handleColors!(plotattributes, arg, get_axis_attr(letter, :foreground_color_axis))
|
||||||
@warn("Skipped $(letter)axis arg $arg")
|
@warn("Skipped $(letter)axis arg $arg")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -446,7 +446,7 @@ function expand_extrema!(sp::Subplot, plotattributes::AKW)
|
|||||||
)
|
)
|
||||||
data = [NaN]
|
data = [NaN]
|
||||||
end
|
end
|
||||||
axis = sp[Symbol(letter, "axis")]
|
axis = sp[get_axis_attr(letter, "axis")]
|
||||||
|
|
||||||
if isa(data, Volume)
|
if isa(data, Volume)
|
||||||
expand_extrema!(sp[:xaxis], data.x_extents)
|
expand_extrema!(sp[:xaxis], data.x_extents)
|
||||||
@ -463,7 +463,7 @@ function expand_extrema!(sp::Subplot, plotattributes::AKW)
|
|||||||
# TODO: need more here... gotta track the discrete reference value
|
# TODO: need more here... gotta track the discrete reference value
|
||||||
# as well as any coord offset (think of boxplot shape coords... they all
|
# as well as any coord offset (think of boxplot shape coords... they all
|
||||||
# correspond to the same x-value)
|
# correspond to the same x-value)
|
||||||
plotattributes[letter], plotattributes[Symbol(letter, "_discrete_indices")] =
|
plotattributes[letter], plotattributes[get_axis_attr(letter, "_discrete_indices")] =
|
||||||
discrete_value!(axis, data)
|
discrete_value!(axis, data)
|
||||||
expand_extrema!(axis, plotattributes[letter])
|
expand_extrema!(axis, plotattributes[letter])
|
||||||
end
|
end
|
||||||
@ -511,8 +511,8 @@ function expand_extrema!(sp::Subplot, plotattributes::AKW)
|
|||||||
if plotattributes[:seriestype] == :heatmap
|
if plotattributes[:seriestype] == :heatmap
|
||||||
for letter in (:x, :y)
|
for letter in (:x, :y)
|
||||||
data = plotattributes[letter]
|
data = plotattributes[letter]
|
||||||
axis = sp[Symbol(letter, "axis")]
|
axis = sp[get_axis_attr(letter, "axis")]
|
||||||
scale = get(plotattributes, Symbol(letter, "scale"), :identity)
|
scale = get(plotattributes, get_axis_attr(letter, "scale"), :identity)
|
||||||
expand_extrema!(axis, heatmap_edges(data, scale))
|
expand_extrema!(axis, heatmap_edges(data, scale))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -586,10 +586,10 @@ end
|
|||||||
function axis_limits(
|
function axis_limits(
|
||||||
sp,
|
sp,
|
||||||
letter,
|
letter,
|
||||||
should_widen = default_should_widen(sp[Symbol(letter, :axis)]),
|
should_widen = default_should_widen(sp[get_axis_attr(letter, :axis)]),
|
||||||
consider_aspect = true,
|
consider_aspect = true,
|
||||||
)
|
)
|
||||||
axis = sp[Symbol(letter, :axis)]
|
axis = sp[get_axis_attr(letter, :axis)]
|
||||||
ex = axis[:extrema]
|
ex = axis[:extrema]
|
||||||
amin, amax = ex.emin, ex.emax
|
amin, amax = ex.emin, ex.emax
|
||||||
lims = axis[:lims]
|
lims = axis[:lims]
|
||||||
@ -724,7 +724,7 @@ end
|
|||||||
# compute the line segments which should be drawn for this axis
|
# compute the line segments which should be drawn for this axis
|
||||||
function axis_drawing_info(sp, letter)
|
function axis_drawing_info(sp, letter)
|
||||||
# find out which axis we are dealing with
|
# find out which axis we are dealing with
|
||||||
asym = Symbol(letter, :axis)
|
asym = get_axis_attr(letter, :axis)
|
||||||
isy = letter === :y
|
isy = letter === :y
|
||||||
oletter = isy ? :x : :y
|
oletter = isy ? :x : :y
|
||||||
oasym = Symbol(oletter, :axis)
|
oasym = Symbol(oletter, :axis)
|
||||||
@ -856,7 +856,7 @@ function axis_drawing_info_3d(sp, letter)
|
|||||||
near_letter = letter in (:x, :z) ? :y : :x
|
near_letter = letter in (:x, :z) ? :y : :x
|
||||||
far_letter = letter in (:x, :y) ? :z : :x
|
far_letter = letter in (:x, :y) ? :z : :x
|
||||||
|
|
||||||
ax = sp[Symbol(letter, :axis)]
|
ax = sp[get_axis_attr(letter, :axis)]
|
||||||
nax = sp[Symbol(near_letter, :axis)]
|
nax = sp[Symbol(near_letter, :axis)]
|
||||||
fax = sp[Symbol(far_letter, :axis)]
|
fax = sp[Symbol(far_letter, :axis)]
|
||||||
|
|
||||||
|
|||||||
@ -247,7 +247,7 @@ function merge_with_base_supported(v::AVec)
|
|||||||
for vi in v
|
for vi in v
|
||||||
if haskey(_axis_defaults, vi)
|
if haskey(_axis_defaults, vi)
|
||||||
for letter in (:x, :y, :z)
|
for letter in (:x, :y, :z)
|
||||||
push!(v, Symbol(letter, vi))
|
push!(v, get_axis_attr(letter, vi))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -331,7 +331,7 @@ end
|
|||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
function pgf_axis(sp::Subplot, letter)
|
function pgf_axis(sp::Subplot, letter)
|
||||||
axis = sp[Symbol(letter, :axis)]
|
axis = sp[get_axis_attr(letter, :axis)]
|
||||||
style = []
|
style = []
|
||||||
kw = KW()
|
kw = KW()
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ function pgf_axis(sp::Subplot, letter)
|
|||||||
framestyle = pgf_framestyle(sp[:framestyle])
|
framestyle = pgf_framestyle(sp[:framestyle])
|
||||||
|
|
||||||
# axis guide
|
# axis guide
|
||||||
kw[Symbol(letter, :label)] = axis[:guide]
|
kw[get_axis_attr(letter, :label)] = axis[:guide]
|
||||||
|
|
||||||
# axis label position
|
# axis label position
|
||||||
labelpos = ""
|
labelpos = ""
|
||||||
@ -378,7 +378,7 @@ function pgf_axis(sp::Subplot, letter)
|
|||||||
# scale
|
# scale
|
||||||
scale = axis[:scale]
|
scale = axis[:scale]
|
||||||
if scale in (:log2, :ln, :log10)
|
if scale in (:log2, :ln, :log10)
|
||||||
kw[Symbol(letter, :mode)] = "log"
|
kw[get_axis_attr(letter, :mode)] = "log"
|
||||||
scale == :ln || push!(style, "log basis $letter=$(scale == :log2 ? 2 : 10)")
|
scale == :ln || push!(style, "log basis $letter=$(scale == :log2 ? 2 : 10)")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -400,8 +400,8 @@ function pgf_axis(sp::Subplot, letter)
|
|||||||
lims =
|
lims =
|
||||||
ispolar(sp) && letter == :x ? rad2deg.(axis_limits(sp, :x)) :
|
ispolar(sp) && letter == :x ? rad2deg.(axis_limits(sp, :x)) :
|
||||||
axis_limits(sp, letter)
|
axis_limits(sp, letter)
|
||||||
kw[Symbol(letter, :min)] = lims[1]
|
kw[get_axis_attr(letter, :min)] = lims[1]
|
||||||
kw[Symbol(letter, :max)] = lims[2]
|
kw[get_axis_attr(letter, :max)] = lims[2]
|
||||||
end
|
end
|
||||||
|
|
||||||
if !(axis[:ticks] in (nothing, false, :none, :native)) && framestyle != :none
|
if !(axis[:ticks] in (nothing, false, :none, :native)) && framestyle != :none
|
||||||
|
|||||||
@ -369,7 +369,7 @@ function gaston_parse_axes_args(
|
|||||||
|
|
||||||
for letter in (:x, :y, :z)
|
for letter in (:x, :y, :z)
|
||||||
(letter == :z && dims == 2) && continue
|
(letter == :z && dims == 2) && continue
|
||||||
axis = sp.attr[Symbol(letter, :axis)]
|
axis = sp.attr[get_axis_attr(letter, :axis)]
|
||||||
# label names
|
# label names
|
||||||
push!(
|
push!(
|
||||||
axesconf,
|
axesconf,
|
||||||
|
|||||||
@ -681,7 +681,7 @@ function gr_display(plt::Plot, fmt = "")
|
|||||||
end
|
end
|
||||||
|
|
||||||
function gr_set_tickfont(sp, letter)
|
function gr_set_tickfont(sp, letter)
|
||||||
axis = sp[Symbol(letter, :axis)]
|
axis = sp[get_axis_attr(letter, :axis)]
|
||||||
|
|
||||||
# invalidate alignment changes for small rotations (|θ| < 45°)
|
# invalidate alignment changes for small rotations (|θ| < 45°)
|
||||||
trigger(rot) = abs(sind(rot)) < abs(cosd(rot)) ? 0 : sign(rot)
|
trigger(rot) = abs(sind(rot)) < abs(cosd(rot)) ? 0 : sign(rot)
|
||||||
@ -1467,7 +1467,7 @@ end
|
|||||||
|
|
||||||
function gr_draw_axis(sp, letter, viewport_plotarea)
|
function gr_draw_axis(sp, letter, viewport_plotarea)
|
||||||
ax = axis_drawing_info(sp, letter)
|
ax = axis_drawing_info(sp, letter)
|
||||||
axis = sp[Symbol(letter, :axis)]
|
axis = sp[get_axis_attr(letter, :axis)]
|
||||||
|
|
||||||
# draw segments
|
# draw segments
|
||||||
gr_draw_grid(sp, axis, ax.grid_segments)
|
gr_draw_grid(sp, axis, ax.grid_segments)
|
||||||
@ -1483,7 +1483,7 @@ end
|
|||||||
|
|
||||||
function gr_draw_axis_3d(sp, letter, viewport_plotarea)
|
function gr_draw_axis_3d(sp, letter, viewport_plotarea)
|
||||||
ax = axis_drawing_info_3d(sp, letter)
|
ax = axis_drawing_info_3d(sp, letter)
|
||||||
axis = sp[Symbol(letter, :axis)]
|
axis = sp[get_axis_attr(letter, :axis)]
|
||||||
|
|
||||||
# draw segments
|
# draw segments
|
||||||
gr_draw_grid(sp, axis, ax.grid_segments, gr_polyline3d)
|
gr_draw_grid(sp, axis, ax.grid_segments, gr_polyline3d)
|
||||||
@ -1564,7 +1564,7 @@ function gr_draw_ticks(sp, axis, segments, func = gr_polyline)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function gr_label_ticks(sp, letter, ticks)
|
function gr_label_ticks(sp, letter, ticks)
|
||||||
axis = sp[Symbol(letter, :axis)]
|
axis = sp[get_axis_attr(letter, :axis)]
|
||||||
isy = letter === :y
|
isy = letter === :y
|
||||||
oletter = isy ? :x : :y
|
oletter = isy ? :x : :y
|
||||||
oaxis = sp[Symbol(oletter, :axis)]
|
oaxis = sp[Symbol(oletter, :axis)]
|
||||||
@ -1588,7 +1588,7 @@ function gr_label_ticks_3d(sp, letter, ticks)
|
|||||||
near_letter = letter in (:x, :z) ? :y : :x
|
near_letter = letter in (:x, :z) ? :y : :x
|
||||||
far_letter = letter in (:x, :y) ? :z : :x
|
far_letter = letter in (:x, :y) ? :z : :x
|
||||||
|
|
||||||
ax = sp[Symbol(letter, :axis)]
|
ax = sp[get_axis_attr(letter, :axis)]
|
||||||
nax = sp[Symbol(near_letter, :axis)]
|
nax = sp[Symbol(near_letter, :axis)]
|
||||||
fax = sp[Symbol(far_letter, :axis)]
|
fax = sp[Symbol(far_letter, :axis)]
|
||||||
|
|
||||||
@ -1637,7 +1637,7 @@ function gr_label_ticks_3d(sp, letter, ticks)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function gr_label_axis(sp, letter, viewport_plotarea)
|
function gr_label_axis(sp, letter, viewport_plotarea)
|
||||||
axis = sp[Symbol(letter, :axis)]
|
axis = sp[get_axis_attr(letter, :axis)]
|
||||||
mirror = axis[:mirror]
|
mirror = axis[:mirror]
|
||||||
# guide
|
# guide
|
||||||
if axis[:guide] != ""
|
if axis[:guide] != ""
|
||||||
@ -1681,7 +1681,7 @@ function gr_label_axis(sp, letter, viewport_plotarea)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function gr_label_axis_3d(sp, letter)
|
function gr_label_axis_3d(sp, letter)
|
||||||
ax = sp[Symbol(letter, :axis)]
|
ax = sp[get_axis_attr(letter, :axis)]
|
||||||
if ax[:guide] != ""
|
if ax[:guide] != ""
|
||||||
near_letter = letter in (:x, :z) ? :y : :x
|
near_letter = letter in (:x, :z) ? :y : :x
|
||||||
far_letter = letter in (:x, :y) ? :z : :x
|
far_letter = letter in (:x, :y) ? :z : :x
|
||||||
|
|||||||
@ -1194,7 +1194,7 @@ function pgfx_sanitize_plot!(plt)
|
|||||||
end
|
end
|
||||||
# --------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------
|
||||||
function pgfx_axis!(opt::PGFPlotsX.Options, sp::Subplot, letter)
|
function pgfx_axis!(opt::PGFPlotsX.Options, sp::Subplot, letter)
|
||||||
axis = sp[Symbol(letter, :axis)]
|
axis = sp[get_axis_attr(letter, :axis)]
|
||||||
|
|
||||||
# turn off scaled ticks
|
# turn off scaled ticks
|
||||||
push!(opt, "scaled $(letter) ticks" => "false", string(letter, :label) => axis[:guide])
|
push!(opt, "scaled $(letter) ticks" => "false", string(letter, :label) => axis[:guide])
|
||||||
|
|||||||
@ -499,7 +499,7 @@ function plotly_close_shapes(x, y)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function plotly_data(series::Series, letter::Symbol, data)
|
function plotly_data(series::Series, letter::Symbol, data)
|
||||||
axis = series[:subplot][Symbol(letter, :axis)]
|
axis = series[:subplot][get_axis_attr(letter, :axis)]
|
||||||
|
|
||||||
data = if axis[:ticks] == :native && data !== nothing
|
data = if axis[:ticks] == :native && data !== nothing
|
||||||
plotly_native_data(axis, data)
|
plotly_native_data(axis, data)
|
||||||
|
|||||||
@ -827,7 +827,7 @@ end
|
|||||||
|
|
||||||
function py_set_ticks(sp, ax, ticks, letter, env)
|
function py_set_ticks(sp, ax, ticks, letter, env)
|
||||||
ticks == :auto && return
|
ticks == :auto && return
|
||||||
axis = getproperty(ax, Symbol(letter, "axis"))
|
axis = getproperty(ax, get_axis_attr(letter, "axis"))
|
||||||
if ticks == :none || ticks === nothing || ticks == false
|
if ticks == :none || ticks === nothing || ticks == false
|
||||||
kw = KW()
|
kw = KW()
|
||||||
for dir in (:top, :bottom, :left, :right)
|
for dir in (:top, :bottom, :left, :right)
|
||||||
@ -894,7 +894,7 @@ function py_set_scale(ax, sp::Subplot, scale::Symbol, letter::Symbol)
|
|||||||
elseif scale == :log10
|
elseif scale == :log10
|
||||||
10
|
10
|
||||||
end
|
end
|
||||||
axis = sp[Symbol(letter, :axis)]
|
axis = sp[get_axis_attr(letter, :axis)]
|
||||||
kw[Symbol(:linthresh, pyletter)] =
|
kw[Symbol(:linthresh, pyletter)] =
|
||||||
NaNMath.max(1e-16, py_compute_axis_minval(sp, axis))
|
NaNMath.max(1e-16, py_compute_axis_minval(sp, axis))
|
||||||
"symlog"
|
"symlog"
|
||||||
@ -1193,7 +1193,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
|||||||
|
|
||||||
# axis attributes
|
# axis attributes
|
||||||
for letter in (:x, :y, :z)
|
for letter in (:x, :y, :z)
|
||||||
axissym = Symbol(letter, :axis)
|
axissym = get_axis_attr(letter, :axis)
|
||||||
PyPlot.PyCall.hasproperty(ax, axissym) || continue
|
PyPlot.PyCall.hasproperty(ax, axissym) || continue
|
||||||
axis = sp[axissym]
|
axis = sp[axissym]
|
||||||
pyaxis = getproperty(ax, axissym)
|
pyaxis = getproperty(ax, axissym)
|
||||||
|
|||||||
@ -321,7 +321,7 @@ function scalefontsizes(factor::Number)
|
|||||||
|
|
||||||
for letter in (:x, :y, :z)
|
for letter in (:x, :y, :z)
|
||||||
for k in keys(_initial_ax_fontsizes)
|
for k in keys(_initial_ax_fontsizes)
|
||||||
scalefontsize(Symbol(letter, k), factor)
|
scalefontsize(get_axis_attr(letter, k), factor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -343,9 +343,9 @@ function scalefontsizes()
|
|||||||
for letter in (:x, :y, :z)
|
for letter in (:x, :y, :z)
|
||||||
for k in keys(_initial_ax_fontsizes)
|
for k in keys(_initial_ax_fontsizes)
|
||||||
if k in keys(_initial_fontsizes)
|
if k in keys(_initial_fontsizes)
|
||||||
f = default(Symbol(letter, k))
|
f = default(get_axis_attr(letter, k))
|
||||||
factor = f / _initial_fontsizes[k]
|
factor = f / _initial_fontsizes[k]
|
||||||
scalefontsize(Symbol(letter, k), 1.0 / factor)
|
scalefontsize(get_axis_attr(letter, k), 1.0 / factor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -250,12 +250,12 @@ function _subplot_setup(plt::Plot, plotattributes::AKW, kw_list::Vector{KW})
|
|||||||
v = v[series_idx(kw_list, kw)]
|
v = v[series_idx(kw_list, kw)]
|
||||||
end
|
end
|
||||||
for letter in (:x, :y, :z)
|
for letter in (:x, :y, :z)
|
||||||
attr[Symbol(letter, k)] = v
|
attr[get_axis_attr(letter, k)] = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for k in (:scale,), letter in (:x, :y, :z)
|
for k in (:scale,), letter in (:x, :y, :z)
|
||||||
# Series recipes may need access to this information
|
# Series recipes may need access to this information
|
||||||
lk = Symbol(letter, k)
|
lk = get_axis_attr(letter, k)
|
||||||
if haskey(attr, lk)
|
if haskey(attr, lk)
|
||||||
kw[lk] = attr[lk]
|
kw[lk] = attr[lk]
|
||||||
end
|
end
|
||||||
|
|||||||
@ -77,3 +77,21 @@ function plotattr(attrtype::Symbol, attribute::AbstractString)
|
|||||||
def == "" ? "" : " default: $(printnothing(def))",
|
def == "" ? "" : " default: $(printnothing(def))",
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
axisattrcache = Dict{Symbol, Dict{Symbol, Symbol}}()
|
||||||
|
|
||||||
|
function get_axis_attr(letter, keyword)
|
||||||
|
lt = if haskey(axisattrcache, letter)
|
||||||
|
axisattrcache[letter]
|
||||||
|
else
|
||||||
|
axisattrcache[letter] = Dict{Symbol, Symbol}()
|
||||||
|
end
|
||||||
|
|
||||||
|
lk = if haskey(lt, keyword)
|
||||||
|
lt[keyword]
|
||||||
|
else
|
||||||
|
lt[keyword] = Symbol(letter, keyword)
|
||||||
|
end
|
||||||
|
|
||||||
|
return lk
|
||||||
|
end
|
||||||
|
|||||||
@ -816,7 +816,7 @@ end
|
|||||||
function extend_series_data!(series::Series, v, letter)
|
function extend_series_data!(series::Series, v, letter)
|
||||||
copy_series!(series, letter)
|
copy_series!(series, letter)
|
||||||
d = extend_by_data!(series[letter], v)
|
d = extend_by_data!(series[letter], v)
|
||||||
expand_extrema!(series[:subplot][Symbol(letter, :axis)], d)
|
expand_extrema!(series[:subplot][get_axis_attr(letter, :axis)], d)
|
||||||
return d
|
return d
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user