From 274fdd11a491040a9fcb7efd7c1b3dbbcbe4396b Mon Sep 17 00:00:00 2001 From: Nicholas Bauer Date: Fri, 27 Aug 2021 01:35:16 -0400 Subject: [PATCH] Generalized axis symbol lookup elsewhere --- src/args.jl | 84 +++++++++++++---------------- src/axes.jl | 42 +++++++-------- src/backends.jl | 2 +- src/backends/deprecated/pgfplots.jl | 10 ++-- src/backends/gaston.jl | 2 +- src/backends/gr.jl | 14 ++--- src/backends/pgfplotsx.jl | 2 +- src/backends/plotly.jl | 2 +- src/backends/pyplot.jl | 6 +-- src/components.jl | 6 +-- src/pipeline.jl | 4 +- src/plotattr.jl | 18 +++++++ src/utils.jl | 2 +- 13 files changed, 100 insertions(+), 94 deletions(-) diff --git a/src/args.jl b/src/args.jl index e07bb3ba..1a85d935 100644 --- a/src/args.jl +++ b/src/args.jl @@ -276,7 +276,7 @@ function hasgrid(arg::Symbol, letter) arg in (:all, :both, :on) || occursin(string(letter), string(arg)) else @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 end @@ -316,7 +316,7 @@ function showaxis(arg::Symbol, letter) arg in (:all, :both, :on, :yes) || occursin(string(letter), string(arg)) else @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 end @@ -573,7 +573,7 @@ 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(Symbol(letter, k), Symbol(letter, "_", k)) + add_aliases(get_axis_attr(letter, k), get_axis_attr(letter, "_", k)) end const _all_defaults = KW[_series_defaults, _plot_defaults, _subplot_defaults] @@ -1004,7 +1004,7 @@ function parse_axis_kw(s::Symbol) s = string(s) for letter in ('x', 'y', 'z') 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 return nothing @@ -1216,69 +1216,69 @@ end function processGridArg!(plotattributes::AKW, arg, letter) 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) - plotattributes[Symbol(letter, :gridstyle)] = arg + plotattributes[get_axis_attr(letter, :gridstyle)] = arg elseif typeof(arg) <: Stroke arg.width === nothing || - (plotattributes[Symbol(letter, :gridlinewidth)] = arg.width) + (plotattributes[get_axis_attr(letter, :gridlinewidth)] = arg.width) 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.alpha === nothing || (plotattributes[Symbol(letter, :gridalpha)] = arg.alpha) - arg.style === nothing || (plotattributes[Symbol(letter, :gridstyle)] = arg.style) + arg.alpha === nothing || (plotattributes[get_axis_attr(letter, :gridalpha)] = arg.alpha) + arg.style === nothing || (plotattributes[get_axis_attr(letter, :gridstyle)] = arg.style) # linealpha elseif allAlphas(arg) - plotattributes[Symbol(letter, :gridalpha)] = arg + plotattributes[get_axis_attr(letter, :gridalpha)] = arg # linewidth elseif allReals(arg) - plotattributes[Symbol(letter, :gridlinewidth)] = arg + plotattributes[get_axis_attr(letter, :gridlinewidth)] = arg # 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.") end end function processMinorGridArg!(plotattributes::AKW, arg, letter) 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) - plotattributes[Symbol(letter, :minorgridstyle)] = arg - plotattributes[Symbol(letter, :minorgrid)] = true + plotattributes[get_axis_attr(letter, :minorgridstyle)] = arg + plotattributes[get_axis_attr(letter, :minorgrid)] = true elseif typeof(arg) <: Stroke arg.width === nothing || - (plotattributes[Symbol(letter, :minorgridlinewidth)] = arg.width) + (plotattributes[get_axis_attr(letter, :minorgridlinewidth)] = arg.width) 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.alpha === nothing || - (plotattributes[Symbol(letter, :minorgridalpha)] = arg.alpha) + (plotattributes[get_axis_attr(letter, :minorgridalpha)] = arg.alpha) arg.style === nothing || - (plotattributes[Symbol(letter, :minorgridstyle)] = arg.style) - plotattributes[Symbol(letter, :minorgrid)] = true + (plotattributes[get_axis_attr(letter, :minorgridstyle)] = arg.style) + plotattributes[get_axis_attr(letter, :minorgrid)] = true # linealpha elseif allAlphas(arg) - plotattributes[Symbol(letter, :minorgridalpha)] = arg - plotattributes[Symbol(letter, :minorgrid)] = true + plotattributes[get_axis_attr(letter, :minorgridalpha)] = arg + plotattributes[get_axis_attr(letter, :minorgrid)] = true # linewidth elseif allReals(arg) - plotattributes[Symbol(letter, :minorgridlinewidth)] = arg - plotattributes[Symbol(letter, :minorgrid)] = true + plotattributes[get_axis_attr(letter, :minorgridlinewidth)] = arg + plotattributes[get_axis_attr(letter, :minorgrid)] = true # color - elseif handleColors!(plotattributes, arg, Symbol(letter, :foreground_color_minor_grid)) - plotattributes[Symbol(letter, :minorgrid)] = true + elseif handleColors!(plotattributes, arg, get_axis_attr(letter, :foreground_color_minor_grid)) + plotattributes[get_axis_attr(letter, :minorgrid)] = true else @warn("Skipped grid arg $arg.") end @@ -1344,7 +1344,7 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW) end # handle axis args for letter in (:x, :y, :z) - asym = Symbol(letter, :axis) + asym = get_axis_attr(letter, :axis) args = RecipesPipeline.pop_kw!(plotattributes, asym, ()) if !(typeof(args) <: Axis) for arg in wraptuple(args) @@ -1371,7 +1371,7 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW) end # handle individual axes grid args for letter in (:x, :y, :z) - gridsym = Symbol(letter, :grid) + gridsym = get_axis_attr(letter, :grid) args = RecipesPipeline.pop_kw!(plotattributes, gridsym, ()) for arg in wraptuple(args) processGridArg!(plotattributes, arg, letter) @@ -1386,7 +1386,7 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW) end # handle individual axes grid args for letter in (:x, :y, :z) - gridsym = Symbol(letter, :minorgrid) + gridsym = get_axis_attr(letter, :minorgrid) args = RecipesPipeline.pop_kw!(plotattributes, gridsym, ()) for arg in wraptuple(args) processMinorGridArg!(plotattributes, arg, letter) @@ -1397,16 +1397,16 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW) args = RecipesPipeline.pop_kw!(plotattributes, fontname, ()) for arg in wraptuple(args) for letter in (:x, :y, :z) - processFontArg!(plotattributes, Symbol(letter, fontname), arg) + processFontArg!(plotattributes, get_axis_attr(letter, fontname), arg) end end end # handle individual axes font args for letter in (:x, :y, :z) 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) - processFontArg!(plotattributes, Symbol(letter, fontname), arg) + processFontArg!(plotattributes, get_axis_attr(letter, fontname), arg) end end end @@ -1415,7 +1415,7 @@ function RecipesPipeline.preprocess_attributes!(plotattributes::AKW) if haskey(plotattributes, k) && k !== :link v = plotattributes[k] for letter in (:x, :y, :z) - lk = Symbol(letter, k) + lk = get_axis_attr(letter, k) if !is_explicit(plotattributes, lk) plotattributes[lk] = v end @@ -1905,8 +1905,6 @@ function _update_axis( _update_axis_links(plt, axis, letter) return end - -axisattrcache = Dict{Symbol, Dict{Symbol, Symbol}}() function _update_axis( axis::Axis, @@ -1924,17 +1922,7 @@ function _update_axis( end # then get those args that were passed with a leading letter: `xlabel = "X"` - lt = if haskey(axisattrcache, letter) - axisattrcache[letter] - else - axisattrcache[letter] = Dict{Symbol, Symbol}() - end - - lk = if haskey(lt, k) - lt[k] - else - lt[k] = Symbol(letter, k) - end + lk = get_axis_attr(letter, k) if haskey(plotattributes_in, lk) kw[k] = slice_arg(plotattributes_in[lk], subplot_index) @@ -1992,7 +1980,7 @@ function _update_subplot_args( lims_warned = false for letter in (:x, :y, :z) _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 if !lims_warned && diff --git a/src/axes.jl b/src/axes.jl index 31c339ee..3897c277 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -23,7 +23,7 @@ function Axis(sp::Subplot, letter::Symbol, args...; kw...) end function get_axis(sp::Subplot, letter::Symbol) - axissym = Symbol(letter, :axis) + axissym = get_axis_attr(letter, :axis) if haskey(sp.attr, axissym) sp.attr[axissym] else @@ -35,40 +35,40 @@ function process_axis_arg!(plotattributes::AKW, arg, letter = "") T = typeof(arg) arg = get(_scaleAliases, arg, arg) if typeof(arg) <: Font - plotattributes[Symbol(letter, :tickfont)] = arg - plotattributes[Symbol(letter, :guidefont)] = arg + plotattributes[get_axis_attr(letter, :tickfont)] = arg + plotattributes[get_axis_attr(letter, :guidefont)] = arg elseif arg in _allScales - plotattributes[Symbol(letter, :scale)] = arg + plotattributes[get_axis_attr(letter, :scale)] = arg elseif arg in (:flip, :invert, :inverted) - plotattributes[Symbol(letter, :flip)] = true + plotattributes[get_axis_attr(letter, :flip)] = true elseif T <: AbstractString - plotattributes[Symbol(letter, :guide)] = arg + plotattributes[get_axis_attr(letter, :guide)] = arg # xlims/ylims elseif (T <: Tuple || T <: AVec) && length(arg) == 2 sym = typeof(arg[1]) <: Number ? :lims : :ticks - plotattributes[Symbol(letter, sym)] = arg + plotattributes[get_axis_attr(letter, sym)] = arg # xticks/yticks elseif T <: AVec - plotattributes[Symbol(letter, :ticks)] = arg + plotattributes[get_axis_attr(letter, :ticks)] = arg elseif arg === nothing - plotattributes[Symbol(letter, :ticks)] = [] + plotattributes[get_axis_attr(letter, :ticks)] = [] 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 - plotattributes[Symbol(letter, :rotation)] = arg + plotattributes[get_axis_attr(letter, :rotation)] = arg 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") end end @@ -446,7 +446,7 @@ function expand_extrema!(sp::Subplot, plotattributes::AKW) ) data = [NaN] end - axis = sp[Symbol(letter, "axis")] + axis = sp[get_axis_attr(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[Symbol(letter, "_discrete_indices")] = + plotattributes[letter], plotattributes[get_axis_attr(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[Symbol(letter, "axis")] - scale = get(plotattributes, Symbol(letter, "scale"), :identity) + axis = sp[get_axis_attr(letter, "axis")] + scale = get(plotattributes, get_axis_attr(letter, "scale"), :identity) expand_extrema!(axis, heatmap_edges(data, scale)) end end @@ -586,10 +586,10 @@ end function axis_limits( sp, letter, - should_widen = default_should_widen(sp[Symbol(letter, :axis)]), + should_widen = default_should_widen(sp[get_axis_attr(letter, :axis)]), consider_aspect = true, ) - axis = sp[Symbol(letter, :axis)] + axis = sp[get_axis_attr(letter, :axis)] ex = axis[:extrema] amin, amax = ex.emin, ex.emax lims = axis[:lims] @@ -724,7 +724,7 @@ end # compute the line segments which should be drawn for this axis function axis_drawing_info(sp, letter) # find out which axis we are dealing with - asym = Symbol(letter, :axis) + asym = get_axis_attr(letter, :axis) isy = letter === :y oletter = isy ? :x : :y oasym = Symbol(oletter, :axis) @@ -856,7 +856,7 @@ function axis_drawing_info_3d(sp, letter) near_letter = letter in (:x, :z) ? :y : :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)] fax = sp[Symbol(far_letter, :axis)] diff --git a/src/backends.jl b/src/backends.jl index 09247960..a5f5cb91 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -247,7 +247,7 @@ function merge_with_base_supported(v::AVec) for vi in v if haskey(_axis_defaults, vi) for letter in (:x, :y, :z) - push!(v, Symbol(letter, vi)) + push!(v, get_axis_attr(letter, vi)) end end end diff --git a/src/backends/deprecated/pgfplots.jl b/src/backends/deprecated/pgfplots.jl index 4c9f1ea3..87530638 100644 --- a/src/backends/deprecated/pgfplots.jl +++ b/src/backends/deprecated/pgfplots.jl @@ -331,7 +331,7 @@ end # ---------------------------------------------------------------- function pgf_axis(sp::Subplot, letter) - axis = sp[Symbol(letter, :axis)] + axis = sp[get_axis_attr(letter, :axis)] style = [] kw = KW() @@ -342,7 +342,7 @@ function pgf_axis(sp::Subplot, letter) framestyle = pgf_framestyle(sp[:framestyle]) # axis guide - kw[Symbol(letter, :label)] = axis[:guide] + kw[get_axis_attr(letter, :label)] = axis[:guide] # axis label position labelpos = "" @@ -378,7 +378,7 @@ function pgf_axis(sp::Subplot, letter) # scale scale = axis[:scale] 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)") end @@ -400,8 +400,8 @@ function pgf_axis(sp::Subplot, letter) lims = ispolar(sp) && letter == :x ? rad2deg.(axis_limits(sp, :x)) : axis_limits(sp, letter) - kw[Symbol(letter, :min)] = lims[1] - kw[Symbol(letter, :max)] = lims[2] + kw[get_axis_attr(letter, :min)] = lims[1] + kw[get_axis_attr(letter, :max)] = lims[2] end if !(axis[:ticks] in (nothing, false, :none, :native)) && framestyle != :none diff --git a/src/backends/gaston.jl b/src/backends/gaston.jl index cd0ccc4a..3fb15b80 100644 --- a/src/backends/gaston.jl +++ b/src/backends/gaston.jl @@ -369,7 +369,7 @@ function gaston_parse_axes_args( for letter in (:x, :y, :z) (letter == :z && dims == 2) && continue - axis = sp.attr[Symbol(letter, :axis)] + axis = sp.attr[get_axis_attr(letter, :axis)] # label names push!( axesconf, diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 42dcffc3..0dc5c1a5 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -681,7 +681,7 @@ function gr_display(plt::Plot, fmt = "") end 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°) trigger(rot) = abs(sind(rot)) < abs(cosd(rot)) ? 0 : sign(rot) @@ -1467,7 +1467,7 @@ end function gr_draw_axis(sp, letter, viewport_plotarea) ax = axis_drawing_info(sp, letter) - axis = sp[Symbol(letter, :axis)] + axis = sp[get_axis_attr(letter, :axis)] # draw segments gr_draw_grid(sp, axis, ax.grid_segments) @@ -1483,7 +1483,7 @@ end function gr_draw_axis_3d(sp, letter, viewport_plotarea) ax = axis_drawing_info_3d(sp, letter) - axis = sp[Symbol(letter, :axis)] + axis = sp[get_axis_attr(letter, :axis)] # draw segments 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 function gr_label_ticks(sp, letter, ticks) - axis = sp[Symbol(letter, :axis)] + axis = sp[get_axis_attr(letter, :axis)] isy = letter === :y oletter = isy ? :x : :y 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 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)] fax = sp[Symbol(far_letter, :axis)] @@ -1637,7 +1637,7 @@ function gr_label_ticks_3d(sp, letter, ticks) end function gr_label_axis(sp, letter, viewport_plotarea) - axis = sp[Symbol(letter, :axis)] + axis = sp[get_axis_attr(letter, :axis)] mirror = axis[:mirror] # guide if axis[:guide] != "" @@ -1681,7 +1681,7 @@ function gr_label_axis(sp, letter, viewport_plotarea) end function gr_label_axis_3d(sp, letter) - ax = sp[Symbol(letter, :axis)] + ax = sp[get_axis_attr(letter, :axis)] if ax[:guide] != "" near_letter = letter in (:x, :z) ? :y : :x far_letter = letter in (:x, :y) ? :z : :x diff --git a/src/backends/pgfplotsx.jl b/src/backends/pgfplotsx.jl index e63bd9ae..7b7508ce 100644 --- a/src/backends/pgfplotsx.jl +++ b/src/backends/pgfplotsx.jl @@ -1194,7 +1194,7 @@ function pgfx_sanitize_plot!(plt) end # -------------------------------------------------------------------------------------- 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 push!(opt, "scaled $(letter) ticks" => "false", string(letter, :label) => axis[:guide]) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index adc9baa5..337d844a 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -499,7 +499,7 @@ function plotly_close_shapes(x, y) end 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 plotly_native_data(axis, data) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 0df6a3a0..5fbc3ac8 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -827,7 +827,7 @@ end function py_set_ticks(sp, ax, ticks, letter, env) ticks == :auto && return - axis = getproperty(ax, Symbol(letter, "axis")) + axis = getproperty(ax, get_axis_attr(letter, "axis")) if ticks == :none || ticks === nothing || ticks == false kw = KW() 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 10 end - axis = sp[Symbol(letter, :axis)] + axis = sp[get_axis_attr(letter, :axis)] kw[Symbol(:linthresh, pyletter)] = NaNMath.max(1e-16, py_compute_axis_minval(sp, axis)) "symlog" @@ -1193,7 +1193,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) # axis attributes for letter in (:x, :y, :z) - axissym = Symbol(letter, :axis) + axissym = get_axis_attr(letter, :axis) PyPlot.PyCall.hasproperty(ax, axissym) || continue axis = sp[axissym] pyaxis = getproperty(ax, axissym) diff --git a/src/components.jl b/src/components.jl index e8eadc72..e56a2c44 100644 --- a/src/components.jl +++ b/src/components.jl @@ -321,7 +321,7 @@ function scalefontsizes(factor::Number) for letter in (:x, :y, :z) for k in keys(_initial_ax_fontsizes) - scalefontsize(Symbol(letter, k), factor) + scalefontsize(get_axis_attr(letter, k), factor) end end end @@ -343,9 +343,9 @@ function scalefontsizes() for letter in (:x, :y, :z) for k in keys(_initial_ax_fontsizes) if k in keys(_initial_fontsizes) - f = default(Symbol(letter, k)) + f = default(get_axis_attr(letter, 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 diff --git a/src/pipeline.jl b/src/pipeline.jl index bb87a69e..e2b2420a 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -250,12 +250,12 @@ function _subplot_setup(plt::Plot, plotattributes::AKW, kw_list::Vector{KW}) v = v[series_idx(kw_list, kw)] end for letter in (:x, :y, :z) - attr[Symbol(letter, k)] = v + attr[get_axis_attr(letter, k)] = v end end for k in (:scale,), letter in (:x, :y, :z) # Series recipes may need access to this information - lk = Symbol(letter, k) + lk = get_axis_attr(letter, k) if haskey(attr, lk) kw[lk] = attr[lk] end diff --git a/src/plotattr.jl b/src/plotattr.jl index c9449830..fbaaf27f 100644 --- a/src/plotattr.jl +++ b/src/plotattr.jl @@ -77,3 +77,21 @@ function plotattr(attrtype::Symbol, attribute::AbstractString) def == "" ? "" : " default: $(printnothing(def))", ) 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 diff --git a/src/utils.jl b/src/utils.jl index 0d69f3a5..7570d2c1 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -816,7 +816,7 @@ end function extend_series_data!(series::Series, v, letter) copy_series!(series, letter) 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 end