diff --git a/src/backends/pgfplots.jl b/src/backends/pgfplots.jl index 145ae7fe..51b96a5b 100644 --- a/src/backends/pgfplots.jl +++ b/src/backends/pgfplots.jl @@ -145,7 +145,6 @@ end # -------------------------------------------------------------------------------------- - function pgf_series(sp::Subplot, series::Series) d = series.d st = d[:seriestype] @@ -173,6 +172,18 @@ function pgf_series(sp::Subplot, series::Series) d[:x], d[:y] end + # PGFPlots can't handle non-Vector? + args = map(a -> if typeof(a) <: AbstractVector && typeof(a) != Vector + collect(a) + else + a + end, args) + # for (i,a) in enumerate(args) + # if typeof(a) <: AbstractVector && typeof(a) != Vector + # args[i] = collect(a) + # end + # end + # include additional style, then add to the kw if haskey(_pgf_series_extrastyle, st) push!(style, _pgf_series_extrastyle[st]) @@ -216,9 +227,12 @@ function pgf_axis(sp::Subplot, letter) end # limits - lims = axis_limits(axis) - kw[Symbol(letter,:min)] = lims[1] - kw[Symbol(letter,:max)] = lims[2] + # TODO: support zlims + if letter != :z + lims = axis_limits(axis) + kw[Symbol(letter,:min)] = lims[1] + kw[Symbol(letter,:max)] = lims[2] + end # return the style list and KW args style, kw diff --git a/src/recipes.jl b/src/recipes.jl index 7ddbaea5..5b5b4779 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -444,6 +444,20 @@ centers(v::AVec) = v[1] + cumsum(diff(v)) () end + +# --------------------------------------------------------------------------- +# scatter 3d + +@recipe function f(::Type{Val{:scatter3d}}, x, y, z) + seriestype := :path3d + if d[:markershape] == :none + markershape := :ellipse + end + linewidth := 0 + linealpha := 0 + () +end + # --------------------------------------------------------------------------- # Box Plot diff --git a/src/series_new.jl b/src/series_new.jl index 3893eeaf..203ed749 100644 --- a/src/series_new.jl +++ b/src/series_new.jl @@ -117,7 +117,10 @@ immutable SliceIt end end # this is the default "type recipe"... just pass the object through -@recipe f{T}(::Type{T}, v::T) = v +@recipe f{T<:Any}(::Type{T}, v::T) = v + +# this should catch unhandled "series recipes" and error with a nice message +@recipe f{V<:Val}(::Type{V}, x, y, z) = error("The backend must not support the series type $V, and there isn't a series recipe defined.") _apply_type_recipe(d, v) = RecipesBase.apply_recipe(d, typeof(v), v)[1].args[1] @@ -156,6 +159,24 @@ end SliceIt, nothing, y, nothing end end + +# if there's more than 3 inputs, it can't be passed directly to SliceIt +# so we'll apply_type_recipe to all of them +@recipe function f(v1, v2, v3, v4, vrest...) + did_replace = false + newargs = map(v -> begin + newv = _apply_type_recipe(d, v) + if newv !== v + did_replace = true + end + newv + end, (v1, v2, v3, v4, vrest...)) + if !did_replace + error("Couldn't process recipe args: $(map(typeof, (v1, v2, v3, v4, vrest...)))") + end + newargs +end + # @recipe f(x, y, z) = SliceIt, apply_recipe(typeof(x), x), apply_recipe(typeof(y), y), apply_recipe(typeof(z), z) # @recipe f(x, y) = SliceIt, apply_recipe(typeof(x), x), apply_recipe(typeof(y), y), nothing # @recipe f(y) = SliceIt, nothing, apply_recipe(typeof(y), y), nothing @@ -323,7 +344,7 @@ end @recipe function f(fx::FuncOrFuncs, fy::FuncOrFuncs, fz::FuncOrFuncs, u::AVec) mapFuncOrFuncs(fx, u), mapFuncOrFuncs(fy, u), mapFuncOrFuncs(fz, u) end -@recipe function f(fx::FuncOrFuncs, fy::FuncOrFuncs, fz::FuncOrFuncs, umin::Number, umax::Number, numPointsn = 200) +@recipe function f(fx::FuncOrFuncs, fy::FuncOrFuncs, fz::FuncOrFuncs, umin::Number, umax::Number, numPoints = 200) fx, fy, fz, linspace(umin, umax, numPoints) end