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,
|
||||
# :levels,
|
||||
]
|
||||
supported_types(::BokehBackend) = [:none, :path, :scatter]
|
||||
supported_types(::BokehBackend) = [:path, :scatter]
|
||||
supported_styles(::BokehBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||
supported_markers(::BokehBackend) = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5]
|
||||
supported_scales(::BokehBackend) = [:identity, :ln]
|
||||
|
||||
@ -24,10 +24,10 @@ supported_args(::GadflyBackend) = [
|
||||
:orientation,
|
||||
]
|
||||
supported_types(::GadflyBackend) = [
|
||||
:none, :line, :path, :steppre, :steppost, :sticks,
|
||||
:scatter, :histogram2d, :hexbin, :histogram,
|
||||
:path,
|
||||
:scatter, :hexbin,
|
||||
:bar,
|
||||
:hline, :vline, :contour, :shape
|
||||
:contour, :shape
|
||||
]
|
||||
supported_styles(::GadflyBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||
supported_markers(::GadflyBackend) = vcat(_allMarkers, Shape)
|
||||
|
||||
@ -38,7 +38,7 @@ supported_args(::PyPlotBackend) = [
|
||||
:clims,
|
||||
]
|
||||
supported_types(::PyPlotBackend) = [
|
||||
:none, :line, :path, :steppre, :steppost, :shape,
|
||||
:path, :steppre, :steppost, :shape,
|
||||
:scatter, :histogram2d, :hexbin, :histogram,
|
||||
:bar, :sticks,
|
||||
: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
|
||||
|
||||
# line plot
|
||||
if st in (:path, :line, :path3d, :steppre, :steppost)
|
||||
if st in (:path, :path3d, :steppre, :steppost)
|
||||
if d[:linewidth] > 0
|
||||
handle = ax[:plot](xyargs...;
|
||||
label = d[:label],
|
||||
@ -491,7 +491,7 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
||||
end
|
||||
|
||||
# add markers?
|
||||
if d[:markershape] != :none && st in (:path, :line, :scatter, :path3d,
|
||||
if d[:markershape] != :none && st in (:path, :scatter, :path3d,
|
||||
:scatter3d, :steppre, :steppost,
|
||||
:bar, :sticks)
|
||||
extrakw = KW()
|
||||
|
||||
@ -44,7 +44,7 @@ supported_args(::QwtBackend) = [
|
||||
:xscale,
|
||||
: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_scales(::QwtBackend) = [:identity, :log10]
|
||||
is_subplot_supported(::QwtBackend) = true
|
||||
|
||||
@ -52,8 +52,8 @@ supported_args(::UnicodePlotsBackend) = [
|
||||
# :z,
|
||||
]
|
||||
supported_types(::UnicodePlotsBackend) = [
|
||||
:path, :steppre, :steppost, :scatter,
|
||||
:histogram2d, :hline, :vline
|
||||
:path, :scatter,
|
||||
:histogram2d
|
||||
]
|
||||
supported_styles(::UnicodePlotsBackend) = [:auto, :solid]
|
||||
supported_markers(::UnicodePlotsBackend) = [:none, :auto, :ellipse]
|
||||
|
||||
@ -55,7 +55,7 @@ supported_args(::WinstonBackend) = [
|
||||
# :yflip,
|
||||
# :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_markers(::WinstonBackend) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5]
|
||||
supported_scales(::WinstonBackend) = [:identity, :log10]
|
||||
|
||||
@ -102,7 +102,19 @@ end
|
||||
Base.show(io::IO, layout::AbstractLayout) = print(io, "$(typeof(layout))$(size(layout))")
|
||||
|
||||
# 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
|
||||
bbox(layout::AbstractLayout) = layout.bbox
|
||||
|
||||
@ -94,6 +94,9 @@ function plot(plt1::Plot, plts_tail::Plot...; kw...)
|
||||
for (idx, sp) in enumerate(plt.subplots)
|
||||
_initialize_subplot(plt, sp)
|
||||
serieslist = series_list(sp)
|
||||
if sp in sp.plt.inset_subplots
|
||||
push!(plt.inset_subplots, sp)
|
||||
end
|
||||
sp.plt = plt
|
||||
sp.attr[:subplot_index] = idx
|
||||
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
|
||||
()
|
||||
end
|
||||
@deps line path
|
||||
|
||||
@recipe function f(::Type{Val{:sticks}}, x, y, z)
|
||||
nx = length(x)
|
||||
n = 3nx
|
||||
newx, newy = zeros(n), zeros(n)
|
||||
for i=1:nx
|
||||
rng = 3i-2:3i
|
||||
newx[rng] = x[i]
|
||||
newy[rng] = [0., y[i], 0.]
|
||||
end
|
||||
x := newx
|
||||
y := newy
|
||||
seriestype := :path
|
||||
()
|
||||
end
|
||||
# @recipe function f(::Type{Val{:sticks}}, x, y, z)
|
||||
# nx = length(x)
|
||||
# n = 3nx
|
||||
# newx, newy = zeros(n), zeros(n)
|
||||
# for i=1:nx
|
||||
# rng = 3i-2:3i
|
||||
# newx[rng] = x[i]
|
||||
# newy[rng] = [0., y[i], 0.]
|
||||
# end
|
||||
# x := newx
|
||||
# y := newy
|
||||
# seriestype := :path
|
||||
# ()
|
||||
# end
|
||||
# @deps sticks path
|
||||
|
||||
@recipe function f(::Type{Val{:hline}}, x, y, z)
|
||||
xmin, xmax = axis_limits(d[:subplot][:xaxis])
|
||||
@ -182,6 +224,7 @@ end
|
||||
seriestype := :path
|
||||
()
|
||||
end
|
||||
@deps hline path
|
||||
|
||||
@recipe function f(::Type{Val{:vline}}, x, y, z)
|
||||
ymin, ymax = axis_limits(d[:subplot][:yaxis])
|
||||
@ -193,6 +236,7 @@ end
|
||||
seriestype := :path
|
||||
()
|
||||
end
|
||||
@deps vline path
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# steps
|
||||
@ -231,6 +275,7 @@ end
|
||||
end
|
||||
()
|
||||
end
|
||||
@deps steppre path scatter
|
||||
|
||||
# create a path from steps
|
||||
@recipe function f(::Type{Val{:steppost}}, x, y, z)
|
||||
@ -251,6 +296,7 @@ end
|
||||
end
|
||||
()
|
||||
end
|
||||
@deps steppost path scatter
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@ -289,6 +335,7 @@ sticks_fillfrom(fr::AVec, i::Integer) = fr[mod1(i, length(fr))]
|
||||
end
|
||||
()
|
||||
end
|
||||
@deps sticks path scatter
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@ -350,6 +397,7 @@ end
|
||||
seriestype := :path
|
||||
()
|
||||
end
|
||||
@deps bar path
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Histograms
|
||||
@ -402,6 +450,7 @@ end
|
||||
seriestype := :bar
|
||||
()
|
||||
end
|
||||
@deps histogram bar
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Histogram 2D
|
||||
@ -443,6 +492,7 @@ centers(v::AVec) = v[1] + cumsum(diff(v))
|
||||
seriestype := :heatmap
|
||||
()
|
||||
end
|
||||
@deps histogram2d heatmap
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@ -458,6 +508,8 @@ end
|
||||
()
|
||||
end
|
||||
|
||||
# note: don't add dependencies because this really isn't a drop-in replacement
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Box Plot
|
||||
|
||||
@ -563,9 +615,8 @@ notch_width(q2, q4, N) = 1.58 * (q4-q2)/sqrt(N)
|
||||
end
|
||||
|
||||
() # expects a tuple returned
|
||||
|
||||
# KW[d]
|
||||
end
|
||||
@deps boxplot shape scatter
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Violin Plot
|
||||
@ -628,9 +679,8 @@ end
|
||||
|
||||
d[:x], d[:y] = shape_coords(shapes)
|
||||
()
|
||||
|
||||
# KW[d]
|
||||
end
|
||||
@deps violin shape
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# density
|
||||
@ -649,6 +699,7 @@ end
|
||||
|
||||
()
|
||||
end
|
||||
@deps density path
|
||||
|
||||
|
||||
|
||||
@ -701,6 +752,7 @@ end
|
||||
d[:x], d[:y] = error_coords(d[:x], d[:y], error_zipit(d[:yerror]))
|
||||
()
|
||||
end
|
||||
@deps yerror path
|
||||
|
||||
@recipe function f(::Type{Val{:xerror}}, x, y, z)
|
||||
error_style!(d)
|
||||
@ -708,6 +760,7 @@ end
|
||||
d[:y], d[:x] = error_coords(d[:y], d[:x], error_zipit(d[:xerror]))
|
||||
()
|
||||
end
|
||||
@deps xerror path
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@ -807,6 +860,7 @@ end
|
||||
end
|
||||
()
|
||||
end
|
||||
@deps quiver shape path
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user