This commit is contained in:
Thomas Breloff 2016-05-13 22:53:32 -04:00
parent 76572b990b
commit 290b17a5f9
4 changed files with 26 additions and 8 deletions

View File

@ -48,12 +48,13 @@ include("backends/web.jl")
plot(pkg::AbstractBackend; kw...) = error("plot($pkg; kw...) is not implemented") plot(pkg::AbstractBackend; kw...) = error("plot($pkg; kw...) is not implemented")
plot!(pkg::AbstractBackend, plt::Plot; kw...) = error("plot!($pkg, plt; kw...) is not implemented") plot!(pkg::AbstractBackend, plt::Plot; kw...) = error("plot!($pkg, plt; kw...) is not implemented")
_update_plot(pkg::AbstractBackend, plt::Plot, d::KW) = error("_update_plot($pkg, plt, d) is not implemented") _update_plot(pkg::AbstractBackend, plt::Plot, d::KW) = error("_update_plot($pkg, plt, d) is not implemented")
_update_plot_pos_size{P<:AbstractBackend}(plt::AbstractPlot{P}, d::KW) = nothing
subplot(pkg::AbstractBackend; kw...) = error("subplot($pkg; kw...) is not implemented") subplot(pkg::AbstractBackend; kw...) = error("subplot($pkg; kw...) is not implemented")
subplot!(pkg::AbstractBackend, subplt::Subplot; kw...) = error("subplot!($pkg, subplt; kw...) is not implemented") subplot!(pkg::AbstractBackend, subplt::Subplot; kw...) = error("subplot!($pkg, subplt; kw...) is not implemented")
# don't do anything as a default # don't do anything as a default
_before_add_series(plt::Plot) = nothing _before_add_series(plt::Plot) = nothing
_add_annotations{X,Y,V}(plt::Plot, anns::AVec{Tuple{X,Y,V}}) = nothing
_update_plot_pos_size(plt::AbstractPlot, d::KW) = nothing
# --------------------------------------------------------- # ---------------------------------------------------------

View File

@ -639,7 +639,16 @@ for f in (:length, :size)
@eval Base.$f(surf::Surface, args...) = $f(surf.surf, args...) @eval Base.$f(surf::Surface, args...) = $f(surf.surf, args...)
end end
Base.copy(surf::Surface) = Surface(copy(surf.surf)) Base.copy(surf::Surface) = Surface(copy(surf.surf))
Base.eltype(surf::Surface) = eltype(surf.surf)
function expand_extrema!(a::Axis, surf::Surface)
v = surf.surf
if !isempty(v)
emin, emax = a[:extrema]
a[:extrema] = (min(minimum(v), emin), max(maximum(v), emax))
end
a[:extrema]
end
"For the case of representing a surface as a function of x/y... can possibly avoid allocations." "For the case of representing a surface as a function of x/y... can possibly avoid allocations."
immutable SurfaceFunction <: AbstractSurface immutable SurfaceFunction <: AbstractSurface

View File

@ -200,6 +200,7 @@ function _plot!(plt::Plot, d::KW, args...)
# if there was a grouping, filter the data here # if there was a grouping, filter the data here
_filter_input_data!(kw) _filter_input_data!(kw)
@show typeof((kw[:x], kw[:y], kw[:z]))
# map marker_z if it's a Function # map marker_z if it's a Function
if isa(get(kw, :marker_z, nothing), Function) if isa(get(kw, :marker_z, nothing), Function)
@ -246,6 +247,10 @@ function _plot!(plt::Plot, d::KW, args...)
# @show anns # @show anns
for kw in kw_list
@show typeof((kw[:x], kw[:y], kw[:z]))
end
# merge plot args... this is where we combine all the plot args from the user and # merge plot args... this is where we combine all the plot args from the user and
# from the recipes... axis info, colors, etc # from the recipes... axis info, colors, etc
# TODO: why do i need to check for the subplot key? # TODO: why do i need to check for the subplot key?
@ -256,6 +261,9 @@ function _plot!(plt::Plot, d::KW, args...)
handlePlotColors(plt.backend, plt.plotargs) handlePlotColors(plt.backend, plt.plotargs)
end end
for kw in kw_list
@show typeof((kw[:x], kw[:y], kw[:z]))
end
# this is it folks! # this is it folks!
# TODO: we probably shouldn't use i for tracking series index, but rather explicitly track it in recipes # TODO: we probably shouldn't use i for tracking series index, but rather explicitly track it in recipes

View File

@ -92,7 +92,7 @@ immutable SliceIt end
# the catch-all recipes # the catch-all recipes
@recipe function f(::Type{SliceIt}, x, y, z) @recipe function f(::Type{SliceIt}, x, y, z)
# @show "HERE", typeof((x,y,z)) @show "HERE", typeof((x,y,z))
xs, _ = convertToAnyVector(x, d) xs, _ = convertToAnyVector(x, d)
ys, _ = convertToAnyVector(y, d) ys, _ = convertToAnyVector(y, d)
zs, _ = convertToAnyVector(z, d) zs, _ = convertToAnyVector(z, d)
@ -105,7 +105,7 @@ immutable SliceIt end
end end
mf = length(fillranges) mf = length(fillranges)
@show zs # @show zs
mx = length(xs) mx = length(xs)
my = length(ys) my = length(ys)
@ -115,9 +115,9 @@ immutable SliceIt end
# add a new series # add a new series
di = copy(d) di = copy(d)
xi, yi, zi = xs[mod1(i,mx)], ys[mod1(i,my)], zs[mod1(i,mz)] xi, yi, zi = xs[mod1(i,mx)], ys[mod1(i,my)], zs[mod1(i,mz)]
# @show i, typeof((xi, yi, zi)) @show i, typeof((xi, yi, zi))
di[:x], di[:y], di[:z] = compute_xyz(xi, yi, zi) di[:x], di[:y], di[:z] = compute_xyz(xi, yi, zi)
# @show i, typeof((di[:x], di[:y], di[:z])) @show i, typeof((di[:x], di[:y], di[:z]))
# handle fillrange # handle fillrange
fr = fillranges[mod1(i,mf)] fr = fillranges[mod1(i,mf)]
@ -331,7 +331,7 @@ end
# d[:x], d[:y] = x, y # d[:x], d[:y] = x, y
# end # end
@recipe function f{X,Y}(x::AVec{X}, y::AVec{Y}, zf::Function) @recipe function f(x::AVec, y::AVec, zf::Function)
# x = X <: Number ? sort(x) : x # x = X <: Number ? sort(x) : x
# y = Y <: Number ? sort(y) : y # y = Y <: Number ? sort(y) : y
SliceIt, x, y, Surface(zf, x, y) # TODO: replace with SurfaceFunction when supported SliceIt, x, y, Surface(zf, x, y) # TODO: replace with SurfaceFunction when supported
@ -355,11 +355,11 @@ end
# end # end
# end # end
@recipe function f{X,Y,Z}(x::AVec{X}, y::AVec{Y}, z::AMat{Z}) @recipe function f(x::AVec, y::AVec, z::AMat)
if !like_surface(get(d, :seriestype, :none)) if !like_surface(get(d, :seriestype, :none))
d[:seriestype] = :contour d[:seriestype] = :contour
end end
SliceIt, x, y, Surface{Matrix{Z}}(z) SliceIt, x, y, Surface(z)
end end
# #