From 5250d63a005caa5b03e1639a88461a33800e0b6c Mon Sep 17 00:00:00 2001 From: Nicholas Bauer Date: Sun, 29 Aug 2021 15:26:43 -0400 Subject: [PATCH] More memoizing --- src/axes.jl | 12 ++++++------ src/backends/gr.jl | 8 ++++---- src/backends/pyplot.jl | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/axes.jl b/src/axes.jl index 3897c277..bce50663 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -297,7 +297,7 @@ for l in (:x, :y, :z) end end # get_ticks from axis symbol :x, :y, or :z -get_ticks(sp::Subplot, s::Symbol) = get_ticks(sp, sp[Symbol(s, :axis)]) +get_ticks(sp::Subplot, s::Symbol) = get_ticks(sp, sp[get_axis_attr(s, :axis)]) get_ticks(p::Plot, s::Symbol) = [get_ticks(sp, s) for sp in p.subplots] function get_ticks(ticks::Symbol, cvals::T, dvals, args...) where {T} @@ -393,7 +393,7 @@ end function reset_extrema!(sp::Subplot) for asym in (:x, :y, :z) - sp[Symbol(asym, :axis)][:extrema] = Extrema() + sp[get_axis_attr(asym, :axis)][:extrema] = Extrema() end for series in sp.series_list expand_extrema!(sp, series.plotattributes) @@ -502,7 +502,7 @@ function expand_extrema!(sp::Subplot, plotattributes::AKW) plotattributes[:bar_width] = _bar_width * ignorenan_minimum(filter(x -> x > 0, diff(sort(data)))) end - axis = sp.attr[Symbol(dsym, :axis)] + axis = sp.attr[get_axis_attr(dsym, :axis)] expand_extrema!(axis, ignorenan_maximum(data) + 0.5maximum(bw)) expand_extrema!(axis, ignorenan_minimum(data) - 0.5minimum(bw)) end @@ -727,7 +727,7 @@ function axis_drawing_info(sp, letter) asym = get_axis_attr(letter, :axis) isy = letter === :y oletter = isy ? :x : :y - oasym = Symbol(oletter, :axis) + oasym = get_axis_attr(oletter, :axis) # get axis objects, ticks and minor ticks ax, oax = sp[asym], sp[oasym] @@ -857,8 +857,8 @@ function axis_drawing_info_3d(sp, letter) far_letter = letter in (:x, :y) ? :z : :x ax = sp[get_axis_attr(letter, :axis)] - nax = sp[Symbol(near_letter, :axis)] - fax = sp[Symbol(far_letter, :axis)] + nax = sp[get_axis_attr(near_letter, :axis)] + fax = sp[get_axis_attr(far_letter, :axis)] amin, amax = axis_limits(sp, letter) namin, namax = axis_limits(sp, near_letter) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 0dc5c1a5..32d58ece 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -1567,7 +1567,7 @@ function gr_label_ticks(sp, letter, ticks) axis = sp[get_axis_attr(letter, :axis)] isy = letter === :y oletter = isy ? :x : :y - oaxis = sp[Symbol(oletter, :axis)] + oaxis = sp[get_axis_attr(oletter, :axis)] oamin, oamax = axis_limits(sp, oletter) gr_set_tickfont(sp, letter) out_factor = ifelse(axis[:tick_direction] === :out, 1.5, 1) @@ -1589,8 +1589,8 @@ function gr_label_ticks_3d(sp, letter, ticks) far_letter = letter in (:x, :y) ? :z : :x ax = sp[get_axis_attr(letter, :axis)] - nax = sp[Symbol(near_letter, :axis)] - fax = sp[Symbol(far_letter, :axis)] + nax = sp[get_axis_attr(near_letter, :axis)] + fax = sp[get_axis_attr(far_letter, :axis)] amin, amax = axis_limits(sp, letter) namin, namax = axis_limits(sp, near_letter) @@ -1600,7 +1600,7 @@ function gr_label_ticks_3d(sp, letter, ticks) # find out which axes we are dealing with i = findfirst(==(letter), (:x, :y, :z)) letters = axes_shift((:x, :y, :z), 1 - i) - asyms = Symbol.(letters, :axis) + asyms = get_axis_attr.(letters, :axis) # get axis objects, ticks and minor ticks # regardless of the `letter` we now use the convention that `x` in variable names refer to diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 5fbc3ac8..7805d16f 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -922,7 +922,7 @@ end function py_set_axis_colors(sp, ax, a::Axis) py_set_spine_color(ax.spines, py_color(a[:foreground_color_border])) - axissym = Symbol(a[:letter], :axis) + axissym = get_axis_attr(a[:letter], :axis) if PyPlot.PyCall.hasproperty(ax, axissym) tickcolor = sp[:framestyle] in (:zerolines, :grid) ?