handle seriestype aliases; handle vector of seriestypes; hvline_limits; added cycle for InputWrapper; turn on GR tests for OSX
This commit is contained in:
parent
4c884651a8
commit
b7a95244db
38
src/plot.jl
38
src/plot.jl
@ -162,8 +162,11 @@ end
|
|||||||
# this method recursively applies series recipes when the seriestype is not supported
|
# this method recursively applies series recipes when the seriestype is not supported
|
||||||
# natively by the backend
|
# natively by the backend
|
||||||
function _apply_series_recipe(plt::Plot, d::KW)
|
function _apply_series_recipe(plt::Plot, d::KW)
|
||||||
|
# replace seriestype aliases
|
||||||
st = d[:seriestype]
|
st = d[:seriestype]
|
||||||
# @show st
|
st = d[:seriestype] = get(_typeAliases, st, st)
|
||||||
|
|
||||||
|
# if it's natively supported, finalize processing and pass along to the backend, otherwise recurse
|
||||||
if st in supported_types()
|
if st in supported_types()
|
||||||
|
|
||||||
# getting ready to add the series... last update to subplot from anything
|
# getting ready to add the series... last update to subplot from anything
|
||||||
@ -256,6 +259,24 @@ function _plot!(plt::Plot, d::KW, args...)
|
|||||||
args = (extractGroupArgs(d[:group], args...), args...)
|
args = (extractGroupArgs(d[:group], args...), args...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
kw_list = KW[]
|
||||||
|
# still_to_process = isempty(args) ? [] : [RecipeData(copy(d), args)]
|
||||||
|
still_to_process = if isempty(args)
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
# if we were passed a vector/matrix of series types and there's more than one row,
|
||||||
|
# we want to duplicate the inputs, once for each seriestype row.
|
||||||
|
sts = get(d, :seriestype, :path)
|
||||||
|
if typeof(sts) <: AbstractArray
|
||||||
|
[begin
|
||||||
|
dc = copy(d)
|
||||||
|
dc[:seriestype] = sts[r,:]
|
||||||
|
RecipeData(dc, args)
|
||||||
|
end for r=1:size(sts,1)]
|
||||||
|
else
|
||||||
|
[RecipeData(copy(d), args)]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# for plotting recipes, swap out the args and update the parameter dictionary
|
# for plotting recipes, swap out the args and update the parameter dictionary
|
||||||
# we are keeping a queue of series that still need to be processed.
|
# we are keeping a queue of series that still need to be processed.
|
||||||
@ -263,8 +284,6 @@ function _plot!(plt::Plot, d::KW, args...)
|
|||||||
# the recipe will return a list a Series objects... the ones that are
|
# the recipe will return a list a Series objects... the ones that are
|
||||||
# finished (no more args) get added to the kw_list, and the rest go into the queue
|
# finished (no more args) get added to the kw_list, and the rest go into the queue
|
||||||
# for processing.
|
# for processing.
|
||||||
kw_list = KW[]
|
|
||||||
still_to_process = isempty(args) ? [] : [RecipeData(copy(d), args)]
|
|
||||||
while !isempty(still_to_process)
|
while !isempty(still_to_process)
|
||||||
|
|
||||||
# grab the first in line to be processed and pass it through apply_recipe
|
# grab the first in line to be processed and pass it through apply_recipe
|
||||||
@ -409,12 +428,13 @@ function _plot!(plt::Plot, d::KW, args...)
|
|||||||
# get the Subplot object to which the series belongs
|
# get the Subplot object to which the series belongs
|
||||||
sp = get(kw, :subplot, :auto)
|
sp = get(kw, :subplot, :auto)
|
||||||
command_idx = kw[:series_plotindex] - kw_list[1][:series_plotindex] + 1
|
command_idx = kw[:series_plotindex] - kw_list[1][:series_plotindex] + 1
|
||||||
sp = if sp == :auto
|
sp = cycle(sp==:auto ? plt.subplots : sp, command_idx)
|
||||||
cycle(plt.subplots, command_idx)
|
# sp = if sp == :auto
|
||||||
# mod1(command_idx, length(plt.subplots))
|
# cycle(plt.subplots, command_idx)
|
||||||
else
|
# # mod1(command_idx, length(plt.subplots))
|
||||||
slice_arg(sp, command_idx)
|
# else
|
||||||
end
|
# cycle(sp, command_idx)
|
||||||
|
# end
|
||||||
sp = kw[:subplot] = get_subplot(plt, sp)
|
sp = kw[:subplot] = get_subplot(plt, sp)
|
||||||
# idx = get_subplot_index(plt, sp)
|
# idx = get_subplot_index(plt, sp)
|
||||||
attr = KW()
|
attr = KW()
|
||||||
|
|||||||
@ -214,8 +214,20 @@ end
|
|||||||
# end
|
# end
|
||||||
# @deps sticks path
|
# @deps sticks path
|
||||||
|
|
||||||
|
function hvline_limits(axis::Axis)
|
||||||
|
vmin, vmax = axis_limits(axis)
|
||||||
|
if vmin >= vmax
|
||||||
|
if isfinite(vmin)
|
||||||
|
vmax = vmin + 1
|
||||||
|
else
|
||||||
|
vmin, vmax = 0.0, 1.1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vmin, vmax
|
||||||
|
end
|
||||||
|
|
||||||
@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 = hvline_limits(d[:subplot][:xaxis])
|
||||||
n = length(y)
|
n = length(y)
|
||||||
newx = repmat(Float64[xmin, xmax, NaN], n)
|
newx = repmat(Float64[xmin, xmax, NaN], n)
|
||||||
newy = vec(Float64[yi for i=1:3,yi=y])
|
newy = vec(Float64[yi for i=1:3,yi=y])
|
||||||
@ -227,7 +239,7 @@ end
|
|||||||
@deps hline path
|
@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 = hvline_limits(d[:subplot][:yaxis])
|
||||||
n = length(y)
|
n = length(y)
|
||||||
newx = vec(Float64[yi for i=1:3,yi=y])
|
newx = vec(Float64[yi for i=1:3,yi=y])
|
||||||
newy = repmat(Float64[ymin, ymax, NaN], n)
|
newy = repmat(Float64[ymin, ymax, NaN], n)
|
||||||
|
|||||||
@ -189,6 +189,9 @@ end
|
|||||||
nop() = nothing
|
nop() = nothing
|
||||||
notimpl() = error("This has not been implemented yet")
|
notimpl() = error("This has not been implemented yet")
|
||||||
|
|
||||||
|
Base.cycle(wrapper::InputWrapper, idx::Int) = wrapper.obj
|
||||||
|
Base.cycle(wrapper::InputWrapper, idx::AVec{Int}) = wrapper.obj
|
||||||
|
|
||||||
Base.cycle(v::AVec, idx::Int) = v[mod1(idx, length(v))]
|
Base.cycle(v::AVec, idx::Int) = v[mod1(idx, length(v))]
|
||||||
Base.cycle(v::AMat, idx::Int) = size(v,1) == 1 ? v[1, mod1(idx, size(v,2))] : v[:, mod1(idx, size(v,2))]
|
Base.cycle(v::AMat, idx::Int) = size(v,1) == 1 ? v[1, mod1(idx, size(v,2))] : v[:, mod1(idx, size(v,2))]
|
||||||
Base.cycle(v, idx::Int) = v
|
Base.cycle(v, idx::Int) = v
|
||||||
|
|||||||
@ -30,7 +30,7 @@ facts("GR") do
|
|||||||
@fact gr() --> Plots.GRBackend()
|
@fact gr() --> Plots.GRBackend()
|
||||||
@fact backend() --> Plots.GRBackend()
|
@fact backend() --> Plots.GRBackend()
|
||||||
|
|
||||||
@linux_only image_comparison_facts(:gr, skip=[30], eps=img_eps)
|
image_comparison_facts(:gr, skip=[30], eps=img_eps)
|
||||||
end
|
end
|
||||||
|
|
||||||
facts("Plotly") do
|
facts("Plotly") do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user