added Surface, removed x/y length assert; added Surface createKWargsList; closes #82
This commit is contained in:
parent
6beadcece8
commit
87bb45d01b
@ -77,6 +77,7 @@ export
|
||||
font,
|
||||
stroke,
|
||||
brush,
|
||||
Surface,
|
||||
OHLC,
|
||||
|
||||
colorscheme,
|
||||
|
||||
@ -120,7 +120,7 @@ function addGadflyLine!(plt::Plot, numlayers::Int, d::Dict, geoms...)
|
||||
kwargs[:xmax] = d[:x] + w
|
||||
elseif lt == :contour
|
||||
# d[:y] = reverse(d[:y])
|
||||
kwargs[:z] = d[:surface]
|
||||
kwargs[:z] = d[:surface].surf
|
||||
addGadflyContColorScale(plt, d[:linecolor])
|
||||
end
|
||||
|
||||
|
||||
@ -320,7 +320,7 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
|
||||
# NOTE: x/y are backwards in pyplot, so we switch the x and y args (also y is reversed),
|
||||
# and take the transpose of the surface matrix
|
||||
x, y = d[:x], d[:y]
|
||||
surf = d[:surface]'
|
||||
surf = d[:surface].surf'
|
||||
handle = plotfunc(x, y, surf, d[:nlevels]; extra_kwargs...)
|
||||
if d[:fillrange] != nothing
|
||||
handle = ax[:contourf](x, y, surf, d[:nlevels]; cmap = getPyPlotColorMap(d[:fillcolor], d[:fillalpha]))
|
||||
|
||||
@ -220,6 +220,15 @@ end
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
"represents a contour or surface mesh"
|
||||
immutable Surface{M<:AMat}
|
||||
# x::AVec
|
||||
# y::AVec
|
||||
surf::M
|
||||
end
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
type OHLC{T<:Real}
|
||||
open::T
|
||||
high::T
|
||||
|
||||
14
src/plot.jl
14
src/plot.jl
@ -232,6 +232,9 @@ convertToAnyVector{T<:Real}(v::AMat{T}; kw...) = Any[v[:,i] for i in 1:size(v,2)
|
||||
# function
|
||||
convertToAnyVector(f::Function; kw...) = Any[f], nothing
|
||||
|
||||
# surface
|
||||
convertToAnyVector(s::Surface; kw...) = Any[s], nothing
|
||||
|
||||
# vector of OHLC
|
||||
convertToAnyVector(v::AVec{OHLC}; kw...) = Any[v], nothing
|
||||
|
||||
@ -260,7 +263,7 @@ function computeXandY(x, y)
|
||||
error("If you want to plot the function `$y`, you need to define the x values somehow!")
|
||||
end
|
||||
x, y = computeX(x,y), computeY(x,y)
|
||||
@assert length(x) == length(y)
|
||||
# @assert length(x) == length(y)
|
||||
x, y
|
||||
end
|
||||
|
||||
@ -363,11 +366,16 @@ function createKWargsList{T<:Real}(plt::PlottingObject, x::AVec, y::AVec, zmat::
|
||||
@assert x == sort(x)
|
||||
@assert y == sort(y)
|
||||
@assert size(zmat) == (length(x), length(y))
|
||||
surf = Array(Any,1,1)
|
||||
surf[1,1] = convert(Matrix{Float64}, zmat)
|
||||
surf = Surface(convert(Matrix{Float64}, zmat))
|
||||
# surf = Array(Any,1,1)
|
||||
# surf[1,1] = convert(Matrix{Float64}, zmat)
|
||||
createKWargsList(plt, x, y; kw..., surface = surf, linetype = :contour)
|
||||
end
|
||||
|
||||
function createKWargsList(plt::PlottingObject, surf::Surface; kw...)
|
||||
createKWargsList(plt, 1:size(surf.surf,1), 1:size(surf.surf,2), convert(Matrix{Float64}, surf.surf); kw...)
|
||||
end
|
||||
|
||||
function createKWargsList(plt::PlottingObject, f::FuncOrFuncs; kw...)
|
||||
error("Can't pass a Function or Vector{Function} for y without also passing x")
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user