series type dependencies and cleanup; bbox anchors in construction; fix for insets
This commit is contained in:
parent
266d2efde5
commit
a018a2c07a
@ -59,7 +59,7 @@ supported_args(::BokehBackend) = [
|
|||||||
# :surface,
|
# :surface,
|
||||||
# :levels,
|
# :levels,
|
||||||
]
|
]
|
||||||
supported_types(::BokehBackend) = [:none, :path, :scatter]
|
supported_types(::BokehBackend) = [:path, :scatter]
|
||||||
supported_styles(::BokehBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
supported_styles(::BokehBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||||
supported_markers(::BokehBackend) = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5]
|
supported_markers(::BokehBackend) = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5]
|
||||||
supported_scales(::BokehBackend) = [:identity, :ln]
|
supported_scales(::BokehBackend) = [:identity, :ln]
|
||||||
|
|||||||
@ -24,10 +24,10 @@ supported_args(::GadflyBackend) = [
|
|||||||
:orientation,
|
:orientation,
|
||||||
]
|
]
|
||||||
supported_types(::GadflyBackend) = [
|
supported_types(::GadflyBackend) = [
|
||||||
:none, :line, :path, :steppre, :steppost, :sticks,
|
:path,
|
||||||
:scatter, :histogram2d, :hexbin, :histogram,
|
:scatter, :hexbin,
|
||||||
:bar,
|
:bar,
|
||||||
:hline, :vline, :contour, :shape
|
:contour, :shape
|
||||||
]
|
]
|
||||||
supported_styles(::GadflyBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
supported_styles(::GadflyBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||||
supported_markers(::GadflyBackend) = vcat(_allMarkers, Shape)
|
supported_markers(::GadflyBackend) = vcat(_allMarkers, Shape)
|
||||||
|
|||||||
@ -38,7 +38,7 @@ supported_args(::PyPlotBackend) = [
|
|||||||
:clims,
|
:clims,
|
||||||
]
|
]
|
||||||
supported_types(::PyPlotBackend) = [
|
supported_types(::PyPlotBackend) = [
|
||||||
:none, :line, :path, :steppre, :steppost, :shape,
|
:path, :steppre, :steppost, :shape,
|
||||||
:scatter, :histogram2d, :hexbin, :histogram,
|
:scatter, :histogram2d, :hexbin, :histogram,
|
||||||
:bar, :sticks,
|
:bar, :sticks,
|
||||||
:hline, :vline, :heatmap, :pie, :image,
|
:hline, :vline, :heatmap, :pie, :image,
|
||||||
@ -412,7 +412,7 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
# for each plotting command, optionally build and add a series handle to the list
|
# for each plotting command, optionally build and add a series handle to the list
|
||||||
|
|
||||||
# line plot
|
# line plot
|
||||||
if st in (:path, :line, :path3d, :steppre, :steppost)
|
if st in (:path, :path3d, :steppre, :steppost)
|
||||||
if d[:linewidth] > 0
|
if d[:linewidth] > 0
|
||||||
handle = ax[:plot](xyargs...;
|
handle = ax[:plot](xyargs...;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
@ -491,7 +491,7 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# add markers?
|
# add markers?
|
||||||
if d[:markershape] != :none && st in (:path, :line, :scatter, :path3d,
|
if d[:markershape] != :none && st in (:path, :scatter, :path3d,
|
||||||
:scatter3d, :steppre, :steppost,
|
:scatter3d, :steppre, :steppost,
|
||||||
:bar, :sticks)
|
:bar, :sticks)
|
||||||
extrakw = KW()
|
extrakw = KW()
|
||||||
|
|||||||
@ -44,7 +44,7 @@ supported_args(::QwtBackend) = [
|
|||||||
:xscale,
|
:xscale,
|
||||||
:yscale,
|
:yscale,
|
||||||
]
|
]
|
||||||
supported_types(::QwtBackend) = [:none, :line, :path, :steppre, :steppost, :sticks, :scatter, :histogram2d, :hexbin, :histogram, :bar, :hline, :vline]
|
supported_types(::QwtBackend) = [:path, :scatter, :hexbin, :bar]
|
||||||
supported_markers(::QwtBackend) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :star8, :hexagon]
|
supported_markers(::QwtBackend) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :star8, :hexagon]
|
||||||
supported_scales(::QwtBackend) = [:identity, :log10]
|
supported_scales(::QwtBackend) = [:identity, :log10]
|
||||||
is_subplot_supported(::QwtBackend) = true
|
is_subplot_supported(::QwtBackend) = true
|
||||||
|
|||||||
@ -52,8 +52,8 @@ supported_args(::UnicodePlotsBackend) = [
|
|||||||
# :z,
|
# :z,
|
||||||
]
|
]
|
||||||
supported_types(::UnicodePlotsBackend) = [
|
supported_types(::UnicodePlotsBackend) = [
|
||||||
:path, :steppre, :steppost, :scatter,
|
:path, :scatter,
|
||||||
:histogram2d, :hline, :vline
|
:histogram2d
|
||||||
]
|
]
|
||||||
supported_styles(::UnicodePlotsBackend) = [:auto, :solid]
|
supported_styles(::UnicodePlotsBackend) = [:auto, :solid]
|
||||||
supported_markers(::UnicodePlotsBackend) = [:none, :auto, :ellipse]
|
supported_markers(::UnicodePlotsBackend) = [:none, :auto, :ellipse]
|
||||||
|
|||||||
@ -55,7 +55,7 @@ supported_args(::WinstonBackend) = [
|
|||||||
# :yflip,
|
# :yflip,
|
||||||
# :z,
|
# :z,
|
||||||
]
|
]
|
||||||
supported_types(::WinstonBackend) = [:none, :line, :path, :sticks, :scatter, :histogram, :bar]
|
supported_types(::WinstonBackend) = [:path, :scatter, :bar]
|
||||||
supported_styles(::WinstonBackend) = [:auto, :solid, :dash, :dot, :dashdot]
|
supported_styles(::WinstonBackend) = [:auto, :solid, :dash, :dot, :dashdot]
|
||||||
supported_markers(::WinstonBackend) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5]
|
supported_markers(::WinstonBackend) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5]
|
||||||
supported_scales(::WinstonBackend) = [:identity, :log10]
|
supported_scales(::WinstonBackend) = [:identity, :log10]
|
||||||
|
|||||||
@ -102,7 +102,19 @@ end
|
|||||||
Base.show(io::IO, layout::AbstractLayout) = print(io, "$(typeof(layout))$(size(layout))")
|
Base.show(io::IO, layout::AbstractLayout) = print(io, "$(typeof(layout))$(size(layout))")
|
||||||
|
|
||||||
# create a new bbox
|
# create a new bbox
|
||||||
bbox(left, top, w, h) = BoundingBox(left, top, w, h)
|
function bbox(x, y, w, h; h_anchor = :left, v_anchor = :top)
|
||||||
|
left = if h_anchor == :left
|
||||||
|
x
|
||||||
|
else
|
||||||
|
x - w * (h_anchor == :right ? 1.0 : 0.5)
|
||||||
|
end
|
||||||
|
top = if v_anchor == :top
|
||||||
|
y
|
||||||
|
else
|
||||||
|
y - h * (v_anchor == :bottom ? 1.0 : 0.5)
|
||||||
|
end
|
||||||
|
BoundingBox(left, top, w, h)
|
||||||
|
end
|
||||||
|
|
||||||
# this is the available area for drawing everything in this layout... as percentages of total canvas
|
# this is the available area for drawing everything in this layout... as percentages of total canvas
|
||||||
bbox(layout::AbstractLayout) = layout.bbox
|
bbox(layout::AbstractLayout) = layout.bbox
|
||||||
|
|||||||
@ -94,6 +94,9 @@ function plot(plt1::Plot, plts_tail::Plot...; kw...)
|
|||||||
for (idx, sp) in enumerate(plt.subplots)
|
for (idx, sp) in enumerate(plt.subplots)
|
||||||
_initialize_subplot(plt, sp)
|
_initialize_subplot(plt, sp)
|
||||||
serieslist = series_list(sp)
|
serieslist = series_list(sp)
|
||||||
|
if sp in sp.plt.inset_subplots
|
||||||
|
push!(plt.inset_subplots, sp)
|
||||||
|
end
|
||||||
sp.plt = plt
|
sp.plt = plt
|
||||||
sp.attr[:subplot_index] = idx
|
sp.attr[:subplot_index] = idx
|
||||||
for series in serieslist
|
for series in serieslist
|
||||||
|
|||||||
@ -53,7 +53,47 @@ end
|
|||||||
|
|
||||||
# ----------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const _series_recipe_deps = Dict()
|
||||||
|
|
||||||
|
function series_recipe_dependencies(st::Symbol, deps::Symbol...)
|
||||||
|
_series_recipe_deps[st] = deps
|
||||||
|
end
|
||||||
|
|
||||||
|
function seriestype_supported(st::Symbol)
|
||||||
|
seriestype_supported(backend(), st)
|
||||||
|
end
|
||||||
|
|
||||||
|
# returns :no, :native, or :recipe depending on how it's supported
|
||||||
|
function seriestype_supported(pkg::AbstractBackend, st::Symbol)
|
||||||
|
# is it natively supported
|
||||||
|
if st in supported_types(pkg)
|
||||||
|
return :native
|
||||||
|
end
|
||||||
|
|
||||||
|
haskey(_series_recipe_deps, st) || return :no
|
||||||
|
|
||||||
|
supported = true
|
||||||
|
for dep in _series_recipe_deps[st]
|
||||||
|
if seriestype_supported(pkg, dep) == :no
|
||||||
|
supported = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
supported ? :recipe : :no
|
||||||
|
end
|
||||||
|
|
||||||
|
macro deps(st, args...)
|
||||||
|
:(series_recipe_dependencies($(quot(st)), $(map(quot, args)...)))
|
||||||
|
end
|
||||||
|
|
||||||
|
# get a list of all seriestypes
|
||||||
|
function all_seriestypes()
|
||||||
|
sts = Set{Symbol}(keys(_series_recipe_deps))
|
||||||
|
for bsym in backends()
|
||||||
|
btype = _backendType[bsym]
|
||||||
|
sts = union(sts, Set{Symbol}(supported_types(btype())))
|
||||||
|
end
|
||||||
|
sort(collect(sts))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------
|
||||||
@ -156,21 +196,23 @@ end
|
|||||||
seriestype := :path
|
seriestype := :path
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
@deps line path
|
||||||
|
|
||||||
@recipe function f(::Type{Val{:sticks}}, x, y, z)
|
# @recipe function f(::Type{Val{:sticks}}, x, y, z)
|
||||||
nx = length(x)
|
# nx = length(x)
|
||||||
n = 3nx
|
# n = 3nx
|
||||||
newx, newy = zeros(n), zeros(n)
|
# newx, newy = zeros(n), zeros(n)
|
||||||
for i=1:nx
|
# for i=1:nx
|
||||||
rng = 3i-2:3i
|
# rng = 3i-2:3i
|
||||||
newx[rng] = x[i]
|
# newx[rng] = x[i]
|
||||||
newy[rng] = [0., y[i], 0.]
|
# newy[rng] = [0., y[i], 0.]
|
||||||
end
|
# end
|
||||||
x := newx
|
# x := newx
|
||||||
y := newy
|
# y := newy
|
||||||
seriestype := :path
|
# seriestype := :path
|
||||||
()
|
# ()
|
||||||
end
|
# end
|
||||||
|
# @deps sticks path
|
||||||
|
|
||||||
@recipe function f(::Type{Val{:hline}}, x, y, z)
|
@recipe function f(::Type{Val{:hline}}, x, y, z)
|
||||||
xmin, xmax = axis_limits(d[:subplot][:xaxis])
|
xmin, xmax = axis_limits(d[:subplot][:xaxis])
|
||||||
@ -182,6 +224,7 @@ end
|
|||||||
seriestype := :path
|
seriestype := :path
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
@deps hline path
|
||||||
|
|
||||||
@recipe function f(::Type{Val{:vline}}, x, y, z)
|
@recipe function f(::Type{Val{:vline}}, x, y, z)
|
||||||
ymin, ymax = axis_limits(d[:subplot][:yaxis])
|
ymin, ymax = axis_limits(d[:subplot][:yaxis])
|
||||||
@ -193,6 +236,7 @@ end
|
|||||||
seriestype := :path
|
seriestype := :path
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
@deps vline path
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# steps
|
# steps
|
||||||
@ -231,6 +275,7 @@ end
|
|||||||
end
|
end
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
@deps steppre path scatter
|
||||||
|
|
||||||
# create a path from steps
|
# create a path from steps
|
||||||
@recipe function f(::Type{Val{:steppost}}, x, y, z)
|
@recipe function f(::Type{Val{:steppost}}, x, y, z)
|
||||||
@ -251,6 +296,7 @@ end
|
|||||||
end
|
end
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
@deps steppost path scatter
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@ -289,6 +335,7 @@ sticks_fillfrom(fr::AVec, i::Integer) = fr[mod1(i, length(fr))]
|
|||||||
end
|
end
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
@deps sticks path scatter
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@ -350,6 +397,7 @@ end
|
|||||||
seriestype := :path
|
seriestype := :path
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
@deps bar path
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Histograms
|
# Histograms
|
||||||
@ -402,6 +450,7 @@ end
|
|||||||
seriestype := :bar
|
seriestype := :bar
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
@deps histogram bar
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Histogram 2D
|
# Histogram 2D
|
||||||
@ -443,6 +492,7 @@ centers(v::AVec) = v[1] + cumsum(diff(v))
|
|||||||
seriestype := :heatmap
|
seriestype := :heatmap
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
@deps histogram2d heatmap
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@ -458,6 +508,8 @@ end
|
|||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# note: don't add dependencies because this really isn't a drop-in replacement
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Box Plot
|
# Box Plot
|
||||||
|
|
||||||
@ -563,9 +615,8 @@ notch_width(q2, q4, N) = 1.58 * (q4-q2)/sqrt(N)
|
|||||||
end
|
end
|
||||||
|
|
||||||
() # expects a tuple returned
|
() # expects a tuple returned
|
||||||
|
|
||||||
# KW[d]
|
|
||||||
end
|
end
|
||||||
|
@deps boxplot shape scatter
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Violin Plot
|
# Violin Plot
|
||||||
@ -628,9 +679,8 @@ end
|
|||||||
|
|
||||||
d[:x], d[:y] = shape_coords(shapes)
|
d[:x], d[:y] = shape_coords(shapes)
|
||||||
()
|
()
|
||||||
|
|
||||||
# KW[d]
|
|
||||||
end
|
end
|
||||||
|
@deps violin shape
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# density
|
# density
|
||||||
@ -649,6 +699,7 @@ end
|
|||||||
|
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
@deps density path
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -701,6 +752,7 @@ end
|
|||||||
d[:x], d[:y] = error_coords(d[:x], d[:y], error_zipit(d[:yerror]))
|
d[:x], d[:y] = error_coords(d[:x], d[:y], error_zipit(d[:yerror]))
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
@deps yerror path
|
||||||
|
|
||||||
@recipe function f(::Type{Val{:xerror}}, x, y, z)
|
@recipe function f(::Type{Val{:xerror}}, x, y, z)
|
||||||
error_style!(d)
|
error_style!(d)
|
||||||
@ -708,6 +760,7 @@ end
|
|||||||
d[:y], d[:x] = error_coords(d[:y], d[:x], error_zipit(d[:xerror]))
|
d[:y], d[:x] = error_coords(d[:y], d[:x], error_zipit(d[:xerror]))
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
@deps xerror path
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@ -807,6 +860,7 @@ end
|
|||||||
end
|
end
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
@deps quiver shape path
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user