pre-populate
This commit is contained in:
parent
04d8beb7b3
commit
a230207c09
43
src/args.jl
43
src/args.jl
@ -571,11 +571,6 @@ function reset_axis_defaults_byletter!()
|
||||
end
|
||||
reset_axis_defaults_byletter!()
|
||||
|
||||
for letter in (:x, :y, :z), k in keys(_axis_defaults)
|
||||
# allow the underscore version too: xguide or x_guide
|
||||
add_aliases(get_attr_symbol(letter, k), Symbol(letter, "_", k))
|
||||
end
|
||||
|
||||
const _all_defaults = KW[_series_defaults, _plot_defaults, _subplot_defaults]
|
||||
|
||||
const _initial_defaults = deepcopy(_all_defaults)
|
||||
@ -620,6 +615,20 @@ const _all_subplot_args = sort(union([_subplot_args; _magic_subplot_args]))
|
||||
const _all_series_args = sort(union([_series_args; _magic_series_args]))
|
||||
const _all_plot_args = _plot_args
|
||||
|
||||
for letter in (:x, :y, :z)
|
||||
_attrsymbolcache[letter] = Dict{Symbol, Symbol}()
|
||||
for k in keys(_axis_defaults)
|
||||
# populate attribute cache
|
||||
lk = Symbol(letter, k)
|
||||
_attrsymbolcache[letter][k] = lk
|
||||
# allow the underscore version too: xguide or x_guide
|
||||
add_aliases(lk, Symbol(letter, "_", k))
|
||||
end
|
||||
for k in _magic_axis_args
|
||||
_attrsymbolcache[letter][k] = Symbol(letter, k)
|
||||
end
|
||||
end
|
||||
|
||||
const _all_args =
|
||||
sort(union([_all_axis_args; _all_subplot_args; _all_series_args; _all_plot_args]))
|
||||
|
||||
@ -2255,3 +2264,27 @@ function _splitdef!(blk, value_args, key_args)
|
||||
end
|
||||
blk
|
||||
end
|
||||
|
||||
|
||||
# const _attrsymbolcache = Dict{Symbol, Dict{Symbol, Symbol}}()
|
||||
|
||||
# get_attr_symbol(letter::Symbol, keyword::String) = get_attr_symbol(letter, Symbol(keyword))
|
||||
|
||||
# function get_attr_symbol(letter::Symbol, keyword::Symbol)
|
||||
# lt = if haskey(_attrsymbolcache, letter)
|
||||
# _attrsymbolcache[letter]
|
||||
# else
|
||||
# _attrsymbolcache[letter] = Dict{Symbol, Symbol}()
|
||||
# end
|
||||
|
||||
# lk = if haskey(lt, keyword)
|
||||
# lt[keyword]
|
||||
# else
|
||||
# lt[keyword] = Symbol(letter, keyword)
|
||||
# end
|
||||
|
||||
# return lk
|
||||
# end
|
||||
|
||||
|
||||
|
||||
|
||||
@ -446,7 +446,7 @@ function expand_extrema!(sp::Subplot, plotattributes::AKW)
|
||||
)
|
||||
data = [NaN]
|
||||
end
|
||||
axis = sp[get_attr_symbol(letter, "axis")]
|
||||
axis = sp[get_attr_symbol(letter, :axis)]
|
||||
|
||||
if isa(data, Volume)
|
||||
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
|
||||
# as well as any coord offset (think of boxplot shape coords... they all
|
||||
# correspond to the same x-value)
|
||||
plotattributes[letter], plotattributes[get_attr_symbol(letter, "_discrete_indices")] =
|
||||
plotattributes[letter], plotattributes[get_attr_symbol(letter, :(_discrete_indices))] =
|
||||
discrete_value!(axis, data)
|
||||
expand_extrema!(axis, plotattributes[letter])
|
||||
end
|
||||
@ -511,8 +511,8 @@ function expand_extrema!(sp::Subplot, plotattributes::AKW)
|
||||
if plotattributes[:seriestype] == :heatmap
|
||||
for letter in (:x, :y)
|
||||
data = plotattributes[letter]
|
||||
axis = sp[get_attr_symbol(letter, "axis")]
|
||||
scale = get(plotattributes, get_attr_symbol(letter, "scale"), :identity)
|
||||
axis = sp[get_attr_symbol(letter, :axis)]
|
||||
scale = get(plotattributes, get_attr_symbol(letter, :scale), :identity)
|
||||
expand_extrema!(axis, heatmap_edges(data, scale))
|
||||
end
|
||||
end
|
||||
|
||||
@ -60,6 +60,14 @@ end
|
||||
# # anything else just gets a bluesred gradient
|
||||
# py_colormap(c, α=nothing) = py_colormap(default_gradient(), α)
|
||||
|
||||
for k in (:linthresh, :base, :label)
|
||||
# add PyPlot specific symbols to cache
|
||||
_attrsymbolcache[k] = Dict{Symbol, Symbol}()
|
||||
for letter in (:x, :y, :z, Symbol(""))
|
||||
_attrsymbolcache[k][letter] = Symbol(k, letter)
|
||||
end
|
||||
end
|
||||
|
||||
py_handle_surface(v) = v
|
||||
py_handle_surface(z::Surface) = z.surf
|
||||
|
||||
@ -827,7 +835,7 @@ end
|
||||
|
||||
function py_set_ticks(sp, ax, ticks, letter, env)
|
||||
ticks == :auto && return
|
||||
axis = getproperty(ax, get_attr_symbol(letter, "axis"))
|
||||
axis = getproperty(ax, get_attr_symbol(letter, :axis))
|
||||
if ticks == :none || ticks === nothing || ticks == false
|
||||
kw = KW()
|
||||
for dir in (:top, :bottom, :left, :right)
|
||||
|
||||
18
src/utils.jl
18
src/utils.jl
@ -1215,22 +1215,8 @@ function mesh3d_triangles(x, y, z, cns)
|
||||
return X, Y, Z
|
||||
end
|
||||
|
||||
# cache joined symbols so they can be looked up instead of constructed each time
|
||||
const _attrsymbolcache = Dict{Symbol, Dict{Symbol, Symbol}}()
|
||||
|
||||
get_attr_symbol(letter::Symbol, keyword::String) = get_attr_symbol(letter, Symbol(keyword))
|
||||
|
||||
function get_attr_symbol(letter::Symbol, keyword::Symbol)
|
||||
lt = if haskey(_attrsymbolcache, letter)
|
||||
_attrsymbolcache[letter]
|
||||
else
|
||||
_attrsymbolcache[letter] = Dict{Symbol, Symbol}()
|
||||
end
|
||||
|
||||
lk = if haskey(lt, keyword)
|
||||
lt[keyword]
|
||||
else
|
||||
lt[keyword] = Symbol(letter, keyword)
|
||||
end
|
||||
|
||||
return lk
|
||||
end
|
||||
get_attr_symbol(letter::Symbol, keyword::Symbol) = _attrsymbolcache[letter][keyword]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user