a bunch of refactors
This commit is contained in:
parent
db685b6ee0
commit
5a1fe30567
@ -879,9 +879,9 @@ function processFontArg!(plotattributes::KW, fontname::Symbol, arg)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
_replace_markershape(shape::Symbol) = get(_markerAliases, shape, shape)
|
@noinline _replace_markershape(shape::Symbol) = get(_markerAliases, shape, shape)
|
||||||
_replace_markershape(shapes::AVec) = map(_replace_markershape, shapes)
|
@noinline _replace_markershape(shapes::AVec) = map(_replace_markershape, shapes)
|
||||||
_replace_markershape(shape) = shape
|
@noinline _replace_markershape(shape) = shape
|
||||||
|
|
||||||
function _add_markershape(plotattributes::KW)
|
function _add_markershape(plotattributes::KW)
|
||||||
# add the markershape if it needs to be added... hack to allow "m=10" to add a shape,
|
# add the markershape if it needs to be added... hack to allow "m=10" to add a shape,
|
||||||
|
|||||||
@ -754,5 +754,5 @@ function axis_drawing_info(sp::Subplot)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
xticks, yticks, xaxis_segs, yaxis_segs, xtick_segs, ytick_segs, xgrid_segs, ygrid_segs, xminorgrid_segs, yminorgrid_segs, xborder_segs, yborder_segs
|
Any[xticks, yticks, xaxis_segs, yaxis_segs, xtick_segs, ytick_segs, xgrid_segs, ygrid_segs, xminorgrid_segs, yminorgrid_segs, xborder_segs, yborder_segs]
|
||||||
end
|
end
|
||||||
|
|||||||
@ -47,17 +47,17 @@ end
|
|||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
# don't do anything as a default
|
# don't do anything as a default
|
||||||
_create_backend_figure(plt::Plot) = nothing
|
@noinline _create_backend_figure(plt::Plot) = nothing
|
||||||
_prepare_plot_object(plt::Plot) = nothing
|
@noinline _prepare_plot_object(plt::Plot) = nothing
|
||||||
_initialize_subplot(plt::Plot, sp::Subplot) = nothing
|
@noinline _initialize_subplot(plt::Plot, sp::Subplot) = nothing
|
||||||
|
|
||||||
_series_added(plt::Plot, series::Series) = nothing
|
@noinline _series_added(plt::Plot, series::Series) = nothing
|
||||||
_series_updated(plt::Plot, series::Series) = nothing
|
@noinline _series_updated(plt::Plot, series::Series) = nothing
|
||||||
|
|
||||||
_before_layout_calcs(plt::Plot) = nothing
|
@noinline _before_layout_calcs(plt::Plot) = nothing
|
||||||
|
|
||||||
title_padding(sp::Subplot) = sp[:title] == "" ? 0mm : sp[:titlefontsize] * pt
|
@noinline title_padding(sp::Subplot) = sp[:title] == "" ? 0mm : sp[:titlefontsize] * pt
|
||||||
guide_padding(axis::Axis) = axis[:guide] == "" ? 0mm : axis[:guidefontsize] * pt
|
@noinline guide_padding(axis::Axis) = axis[:guide] == "" ? 0mm : axis[:guidefontsize] * pt
|
||||||
|
|
||||||
"Returns the (width,height) of a text label."
|
"Returns the (width,height) of a text label."
|
||||||
function text_size(lablen::Int, sz::Number, rot::Number = 0)
|
function text_size(lablen::Int, sz::Number, rot::Number = 0)
|
||||||
@ -123,7 +123,7 @@ function _update_min_padding!(sp::Subplot)
|
|||||||
sp.minpad = (leftpad, toppad, rightpad, bottompad)
|
sp.minpad = (leftpad, toppad, rightpad, bottompad)
|
||||||
end
|
end
|
||||||
|
|
||||||
_update_plot_object(plt::Plot) = nothing
|
@noinline _update_plot_object(plt::Plot) = nothing
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ end
|
|||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
_fallback_default_backend() = backend(GRBackend())
|
@noinline _fallback_default_backend() = backend(GRBackend())
|
||||||
|
|
||||||
function _pick_default_backend()
|
function _pick_default_backend()
|
||||||
env_default = get(ENV, "PLOTS_DEFAULT_BACKEND", "")
|
env_default = get(ENV, "PLOTS_DEFAULT_BACKEND", "")
|
||||||
@ -305,9 +305,8 @@ function _initialize_backend(pkg::AbstractBackend)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
_initialize_backend(pkg::GRBackend) = nothing
|
@noinline _initialize_backend(pkg::GRBackend) = nothing
|
||||||
|
@noinline _initialize_backend(pkg::PlotlyBackend) = nothing
|
||||||
_initialize_backend(pkg::PlotlyBackend) = nothing
|
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|||||||
1017
src/backends/gr.jl
1017
src/backends/gr.jl
File diff suppressed because it is too large
Load Diff
@ -188,29 +188,29 @@ parent_bbox(layout::AbstractLayout) = bbox(parent(layout))
|
|||||||
# padding_h(layout::AbstractLayout) = bottom_padding(layout) + top_padding(layout)
|
# padding_h(layout::AbstractLayout) = bottom_padding(layout) + top_padding(layout)
|
||||||
# padding(layout::AbstractLayout) = (padding_w(layout), padding_h(layout))
|
# padding(layout::AbstractLayout) = (padding_w(layout), padding_h(layout))
|
||||||
|
|
||||||
update_position!(layout::AbstractLayout) = nothing
|
@noinline update_position!(layout::AbstractLayout) = nothing
|
||||||
update_child_bboxes!(layout::AbstractLayout, minimum_perimeter = [0mm,0mm,0mm,0mm]) = nothing
|
@noinline update_child_bboxes!(layout::AbstractLayout, minimum_perimeter = [0mm,0mm,0mm,0mm]) = nothing
|
||||||
|
|
||||||
left(layout::AbstractLayout) = left(bbox(layout))
|
@noinline left(layout::AbstractLayout) = left(bbox(layout))
|
||||||
top(layout::AbstractLayout) = top(bbox(layout))
|
@noinline top(layout::AbstractLayout) = top(bbox(layout))
|
||||||
right(layout::AbstractLayout) = right(bbox(layout))
|
@noinline right(layout::AbstractLayout) = right(bbox(layout))
|
||||||
bottom(layout::AbstractLayout) = bottom(bbox(layout))
|
@noinline bottom(layout::AbstractLayout) = bottom(bbox(layout))
|
||||||
width(layout::AbstractLayout) = width(bbox(layout))
|
@noinline width(layout::AbstractLayout) = width(bbox(layout))
|
||||||
height(layout::AbstractLayout) = height(bbox(layout))
|
@noinline height(layout::AbstractLayout) = height(bbox(layout))
|
||||||
|
|
||||||
# pass these through to the bbox methods if there's no plotarea
|
# pass these through to the bbox methods if there's no plotarea
|
||||||
plotarea(layout::AbstractLayout) = bbox(layout)
|
@noinline plotarea(layout::AbstractLayout) = bbox(layout)
|
||||||
plotarea!(layout::AbstractLayout, bb::BoundingBox) = bbox!(layout, bb)
|
@noinline plotarea!(layout::AbstractLayout, bb::BoundingBox) = bbox!(layout, bb)
|
||||||
|
|
||||||
attr(layout::AbstractLayout, k::Symbol) = layout.attr[k]
|
@noinline attr(layout::AbstractLayout, k::Symbol) = layout.attr[k]
|
||||||
attr(layout::AbstractLayout, k::Symbol, v) = get(layout.attr, k, v)
|
@noinline attr(layout::AbstractLayout, k::Symbol, v) = get(layout.attr, k, v)
|
||||||
attr!(layout::AbstractLayout, v, k::Symbol) = (layout.attr[k] = v)
|
@noinline attr!(layout::AbstractLayout, v, k::Symbol) = (layout.attr[k] = v)
|
||||||
hasattr(layout::AbstractLayout, k::Symbol) = haskey(layout.attr, k)
|
@noinline hasattr(layout::AbstractLayout, k::Symbol) = haskey(layout.attr, k)
|
||||||
|
|
||||||
leftpad(layout::AbstractLayout) = 0mm
|
@noinline leftpad(layout::AbstractLayout) = 0mm
|
||||||
toppad(layout::AbstractLayout) = 0mm
|
@noinline toppad(layout::AbstractLayout) = 0mm
|
||||||
rightpad(layout::AbstractLayout) = 0mm
|
@noinline rightpad(layout::AbstractLayout) = 0mm
|
||||||
bottompad(layout::AbstractLayout) = 0mm
|
@noinline bottompad(layout::AbstractLayout) = 0mm
|
||||||
|
|
||||||
# -----------------------------------------------------------
|
# -----------------------------------------------------------
|
||||||
# RootLayout
|
# RootLayout
|
||||||
@ -349,18 +349,18 @@ function update_child_bboxes!(layout::GridLayout, minimum_perimeter = [0mm,0mm,0
|
|||||||
# # create a matrix for each minimum padding direction
|
# # create a matrix for each minimum padding direction
|
||||||
# _update_min_padding!(layout)
|
# _update_min_padding!(layout)
|
||||||
|
|
||||||
minpad_left = map(leftpad, layout.grid)
|
minpad_left::Matrix{AbsoluteLength} = map(leftpad, layout.grid)
|
||||||
minpad_top = map(toppad, layout.grid)
|
minpad_top::Matrix{AbsoluteLength} = map(toppad, layout.grid)
|
||||||
minpad_right = map(rightpad, layout.grid)
|
minpad_right::Matrix{AbsoluteLength} = map(rightpad, layout.grid)
|
||||||
minpad_bottom = map(bottompad, layout.grid)
|
minpad_bottom::Matrix{AbsoluteLength} = map(bottompad, layout.grid)
|
||||||
|
|
||||||
# get the max horizontal (left and right) padding over columns,
|
# get the max horizontal (left and right) padding over columns,
|
||||||
# and max vertical (bottom and top) padding over rows
|
# and max vertical (bottom and top) padding over rows
|
||||||
# TODO: add extra padding here
|
# TODO: add extra padding here
|
||||||
pad_left = maximum(minpad_left, dims = 1)
|
pad_left::Matrix{AbsoluteLength} = maximum(minpad_left, dims = 1)
|
||||||
pad_top = maximum(minpad_top, dims = 2)
|
pad_top::Matrix{AbsoluteLength} = maximum(minpad_top, dims = 2)
|
||||||
pad_right = maximum(minpad_right, dims = 1)
|
pad_right::Matrix{AbsoluteLength} = maximum(minpad_right, dims = 1)
|
||||||
pad_bottom = maximum(minpad_bottom, dims = 2)
|
pad_bottom::Matrix{AbsoluteLength} = maximum(minpad_bottom, dims = 2)
|
||||||
|
|
||||||
# make sure the perimeter match the parent
|
# make sure the perimeter match the parent
|
||||||
pad_left[1] = max(pad_left[1], minimum_perimeter[1])
|
pad_left[1] = max(pad_left[1], minimum_perimeter[1])
|
||||||
@ -389,14 +389,14 @@ function update_child_bboxes!(layout::GridLayout, minimum_perimeter = [0mm,0mm,0
|
|||||||
child = layout[r,c]
|
child = layout[r,c]
|
||||||
|
|
||||||
# get the top-left corner of this child... the first one is top-left of the parent (i.e. layout)
|
# get the top-left corner of this child... the first one is top-left of the parent (i.e. layout)
|
||||||
child_left = (c == 1 ? left(layout.bbox) : right(layout[r, c-1].bbox))
|
child_left::AbsoluteLength = (c == 1 ? left(layout.bbox) : right(layout[r, c-1].bbox))
|
||||||
child_top = (r == 1 ? top(layout.bbox) : bottom(layout[r-1, c].bbox))
|
child_top::AbsoluteLength = (r == 1 ? top(layout.bbox) : bottom(layout[r-1, c].bbox))
|
||||||
|
|
||||||
# compute plot area
|
# compute plot area
|
||||||
plotarea_left = child_left + pad_left[c]
|
plotarea_left::AbsoluteLength = child_left + pad_left[c]
|
||||||
plotarea_top = child_top + pad_top[r]
|
plotarea_top::AbsoluteLength = child_top + pad_top[r]
|
||||||
plotarea_width = total_plotarea_horizontal * layout.widths[c]
|
plotarea_width::AbsoluteLength = total_plotarea_horizontal * layout.widths[c]
|
||||||
plotarea_height = total_plotarea_vertical * layout.heights[r]
|
plotarea_height::AbsoluteLength = total_plotarea_vertical * layout.heights[r]
|
||||||
plotarea!(child, BoundingBox(plotarea_left, plotarea_top, plotarea_width, plotarea_height))
|
plotarea!(child, BoundingBox(plotarea_left, plotarea_top, plotarea_width, plotarea_height))
|
||||||
|
|
||||||
# compute child bbox
|
# compute child bbox
|
||||||
|
|||||||
@ -228,7 +228,7 @@ closeall() = closeall(backend())
|
|||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# Atom PlotPane
|
# Atom PlotPane
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
function showjuno(io::IO, m, plt)
|
@noinline function showjuno(io::IO, m, plt)
|
||||||
sz = plt[:size]
|
sz = plt[:size]
|
||||||
dpi = plt[:dpi]
|
dpi = plt[:dpi]
|
||||||
thickness_scaling = plt[:thickness_scaling]
|
thickness_scaling = plt[:thickness_scaling]
|
||||||
@ -250,7 +250,7 @@ function showjuno(io::IO, m, plt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _showjuno(io::IO, m::MIME"image/svg+xml", plt)
|
@noinline function _showjuno(io::IO, m::MIME"image/svg+xml", plt)
|
||||||
if Symbol(plt.attr[:html_output_format]) ≠ :svg
|
if Symbol(plt.attr[:html_output_format]) ≠ :svg
|
||||||
throw(MethodError(show, (typeof(m), typeof(plt))))
|
throw(MethodError(show, (typeof(m), typeof(plt))))
|
||||||
else
|
else
|
||||||
@ -258,4 +258,4 @@ function _showjuno(io::IO, m::MIME"image/svg+xml", plt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
_showjuno(io::IO, m, plt) = _show(io, m, plt)
|
@noinline _showjuno(io::IO, m, plt) = _show(io, m, plt)
|
||||||
|
|||||||
@ -23,7 +23,7 @@ end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _preprocess_args(plotattributes::KW, args, still_to_process::Vector{RecipeData})
|
@noinline function _preprocess_args(plotattributes::KW, args, still_to_process::Vector{RecipeData})
|
||||||
# the grouping mechanism is a recipe on a GroupBy object
|
# the grouping mechanism is a recipe on a GroupBy object
|
||||||
# we simply add the GroupBy object to the front of the args list to allow
|
# we simply add the GroupBy object to the front of the args list to allow
|
||||||
# the recipe to be applied
|
# the recipe to be applied
|
||||||
@ -57,7 +57,7 @@ end
|
|||||||
# user recipes
|
# user recipes
|
||||||
|
|
||||||
|
|
||||||
function _process_userrecipes(plt::Plot, plotattributes::KW, args)
|
@noinline function _process_userrecipes(plt::Plot, plotattributes::KW, args)
|
||||||
still_to_process = RecipeData[]
|
still_to_process = RecipeData[]
|
||||||
args = _preprocess_args(plotattributes, args, still_to_process)
|
args = _preprocess_args(plotattributes, args, still_to_process)
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ function _process_userrecipes(plt::Plot, plotattributes::KW, args)
|
|||||||
kw_list
|
kw_list
|
||||||
end
|
end
|
||||||
|
|
||||||
function _process_userrecipe(plt::Plot, kw_list::Vector{KW}, recipedata::RecipeData)
|
@noinline function _process_userrecipe(plt::Plot, kw_list::Vector{KW}, recipedata::RecipeData)
|
||||||
# when the arg tuple is empty, that means there's nothing left to recursively
|
# when the arg tuple is empty, that means there's nothing left to recursively
|
||||||
# process... finish up and add to the kw_list
|
# process... finish up and add to the kw_list
|
||||||
kw = recipedata.plotattributes
|
kw = recipedata.plotattributes
|
||||||
@ -108,7 +108,7 @@ function _process_userrecipe(plt::Plot, kw_list::Vector{KW}, recipedata::RecipeD
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function _preprocess_userrecipe(kw::KW)
|
@noinline function _preprocess_userrecipe(kw::KW)
|
||||||
_add_markershape(kw)
|
_add_markershape(kw)
|
||||||
|
|
||||||
# if there was a grouping, filter the data here
|
# if there was a grouping, filter the data here
|
||||||
@ -302,7 +302,7 @@ end
|
|||||||
|
|
||||||
# getting ready to add the series... last update to subplot from anything
|
# getting ready to add the series... last update to subplot from anything
|
||||||
# that might have been added during series recipes
|
# that might have been added during series recipes
|
||||||
function _prepare_subplot(plt::Plot{T}, plotattributes::KW) where T
|
@noinline function _prepare_subplot(plt::Plot{T}, plotattributes::KW) where T
|
||||||
st::Symbol = plotattributes[:seriestype]
|
st::Symbol = plotattributes[:seriestype]
|
||||||
sp::Subplot{T} = plotattributes[:subplot]
|
sp::Subplot{T} = plotattributes[:subplot]
|
||||||
sp_idx = get_subplot_index(plt, sp)
|
sp_idx = get_subplot_index(plt, sp)
|
||||||
|
|||||||
15
src/plot.jl
15
src/plot.jl
@ -16,7 +16,7 @@ Returns the Plot object for the current plot
|
|||||||
end
|
end
|
||||||
CURRENT_PLOT.nullableplot
|
CURRENT_PLOT.nullableplot
|
||||||
end
|
end
|
||||||
current(plot::AbstractPlot) = (CURRENT_PLOT.nullableplot = plot)
|
@noinline current(plot::AbstractPlot) = (CURRENT_PLOT.nullableplot = plot)
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
@ -175,6 +175,7 @@ function _plot!(plt::Plot{T}, plotattributes::KW, args::Vector{Any}) where {T}
|
|||||||
# "USER RECIPES"
|
# "USER RECIPES"
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
|
|
||||||
|
# 1 second
|
||||||
kw_list = _process_userrecipes(plt, plotattributes, args)
|
kw_list = _process_userrecipes(plt, plotattributes, args)
|
||||||
|
|
||||||
# @info(1)
|
# @info(1)
|
||||||
@ -189,6 +190,7 @@ function _plot!(plt::Plot{T}, plotattributes::KW, args::Vector{Any}) where {T}
|
|||||||
# the plot layout is created, which allows for setting layouts and other plot-wide attributes.
|
# the plot layout is created, which allows for setting layouts and other plot-wide attributes.
|
||||||
# we get inputs which have been fully processed by "user recipes" and "type recipes",
|
# we get inputs which have been fully processed by "user recipes" and "type recipes",
|
||||||
# so we can expect standard vectors, surfaces, etc. No defaults have been set yet.
|
# so we can expect standard vectors, surfaces, etc. No defaults have been set yet.
|
||||||
|
|
||||||
still_to_process = kw_list
|
still_to_process = kw_list
|
||||||
kw_list = KW[]
|
kw_list = KW[]
|
||||||
while !isempty(still_to_process)
|
while !isempty(still_to_process)
|
||||||
@ -203,11 +205,12 @@ function _plot!(plt::Plot{T}, plotattributes::KW, args::Vector{Any}) where {T}
|
|||||||
# Plot/Subplot/Layout setup
|
# Plot/Subplot/Layout setup
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
|
|
||||||
|
# 2.5 seconds
|
||||||
_plot_setup(plt, plotattributes, kw_list)
|
_plot_setup(plt, plotattributes, kw_list)
|
||||||
|
|
||||||
# 6 seconds
|
# 6 seconds
|
||||||
_subplot_setup(plt, plotattributes, kw_list)
|
_subplot_setup(plt, plotattributes, kw_list)
|
||||||
#=
|
|
||||||
# !!! note: At this point, kw_list is fully decomposed into individual series... one KW per series. !!!
|
# !!! note: At this point, kw_list is fully decomposed into individual series... one KW per series. !!!
|
||||||
# !!! The next step is to recursively apply series recipes until the backend supports that series type !!!
|
# !!! The next step is to recursively apply series recipes until the backend supports that series type !!!
|
||||||
|
|
||||||
@ -238,6 +241,7 @@ function _plot!(plt::Plot{T}, plotattributes::KW, args::Vector{Any}) where {T}
|
|||||||
end
|
end
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
|
|
||||||
|
# 7 seconds
|
||||||
current(plt)
|
current(plt)
|
||||||
|
|
||||||
# do we want to force display?
|
# do we want to force display?
|
||||||
@ -246,13 +250,13 @@ function _plot!(plt::Plot{T}, plotattributes::KW, args::Vector{Any}) where {T}
|
|||||||
# end
|
# end
|
||||||
_do_plot_show(plt, plt[:show])
|
_do_plot_show(plt, plt[:show])
|
||||||
plt
|
plt
|
||||||
=#
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# we're getting ready to display/output. prep for layout calcs, then update
|
# we're getting ready to display/output. prep for layout calcs, then update
|
||||||
# the plot object after
|
# the plot object after
|
||||||
function prepare_output(plt::Plot)
|
@noinline function prepare_output(plt::Plot)
|
||||||
|
|
||||||
_before_layout_calcs(plt)
|
_before_layout_calcs(plt)
|
||||||
|
|
||||||
w, h = plt.attr[:size]
|
w, h = plt.attr[:size]
|
||||||
@ -273,9 +277,10 @@ function prepare_output(plt::Plot)
|
|||||||
|
|
||||||
# the backend callback, to reposition subplots, etc
|
# the backend callback, to reposition subplots, etc
|
||||||
_update_plot_object(plt)
|
_update_plot_object(plt)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function backend_object(plt::Plot)
|
@noinline function backend_object(plt::Plot)
|
||||||
prepare_output(plt)
|
prepare_output(plt)
|
||||||
plt.o
|
plt.o
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user