removed nlevels keyword, now an alias to levels; cleanup

This commit is contained in:
Thomas Breloff 2015-12-30 10:13:53 -05:00
parent 489877d6bf
commit 6ac312bd49
6 changed files with 40 additions and 27 deletions

View File

@ -138,8 +138,8 @@ _seriesDefaults[:y] = nothing
_seriesDefaults[:z] = nothing # depth for contour, surface, etc
_seriesDefaults[:zcolor] = nothing # value for color scale
# _seriesDefaults[:surface] = nothing
_seriesDefaults[:nlevels] = 15
_seriesDefaults[:levels] = nothing
# _seriesDefaults[:nlevels] = 15
_seriesDefaults[:levels] = 15
_seriesDefaults[:orientation] = :vertical
@ -284,6 +284,9 @@ end
:foreground_colour => :foreground_color,
:regression => :smooth,
:reg => :smooth,
:nlevels => :levels,
:nlev => :levels,
:levs => :levels,
:xlim => :xlims,
:xlimit => :xlims,
:xlimits => :xlims,

View File

@ -44,7 +44,7 @@ function getLineGeom(d::Dict)
elseif lt == :vline
Gadfly.Geom.vline
elseif lt == :contour
Gadfly.Geom.contour(levels = d[:nlevels])
Gadfly.Geom.contour(levels = d[:levels])
else
nothing
end

View File

@ -292,7 +292,7 @@ function plotly_series(d::Dict; plot_index = nothing)
d_out[:z] = d[:z].surf
# d_out[:showscale] = d[:legend]
if lt == :contour
d_out[:ncontours] = d[:nlevels]
d_out[:ncontours] = d[:levels]
d_out[:contours] = Dict(:coloring => d[:fillrange] != nothing ? "fill" : "lines")
end
d_out[:colorscale] = plotly_colorscale(d[lt == :contour ? :linecolor : :fillcolor])

View File

@ -333,32 +333,33 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
# do the plot
d[:serieshandle] = if ishistlike(lt)
plotfunc(d[:y]; extra_kwargs...)[1]
elseif lt == :contour
# 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[:z].surf'
if d[:levels] != nothing
handle = plotfunc(x, y, surf; levels=d[:levels], extra_kwargs...)
if d[:fillrange] != nothing
handle = ax[:contourf](x, y, surf; levels=d[:levels], cmap = getPyPlotColorMap(d[:fillcolor], d[:fillalpha]))
end
levels = d[:levels]
if isscalar(levels)
extra_args = (levels)
elseif isvector(levels)
extra_args = ()
extra_kwargs[:levels] = levels
else
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]))
end
error("Only numbers and vectors are supported with levels keyword")
end
handle = plotfunc(x, y, surf, extra_args...; extra_kwargs...)
if d[:fillrange] != nothing
extra_kwargs[:cmap] = getPyPlotColorMap(d[:fillcolor], d[:fillalpha])
handle = ax[:contourf](x, y, surf, extra_args...; extra_kwargs...)
end
handle
elseif lt in (:surface,:wireframe)
x, y, z = if isa(d[:x], AMat) && isa(d[:y], AMat)
d[:x], d[:y], d[:z].surf
else
repmat(d[:x]',length(d[:y]),1), repmat(d[:y],1,length(d[:x])), d[:z].surf'
x, y, z = d[:x], d[:y], d[:z].surf
if !ismatrix(x) || !ismatrix(y)
x = repmat(x', length(y), 1)
y = repmat(y, 1, length(x))
z = z'
end
# x = isa(d[:x], AMat) ? d[:x] : repmat(d[:x]',length(d[:y]),1)
# y = isa(d[:y], AMat) ? d[:y] : repmat(d[:y],1,length(d[:x]))
# z = isa(d[:x], AMat) ? d[:z].surf : d[:z].surf'
plotfunc(x, y, z; extra_kwargs...)
elseif lt in _3dTypes
plotfunc(d[:x], d[:y], d[:z]; extra_kwargs...)

View File

@ -74,7 +74,7 @@ supportedArgs(::GadflyPackage) = [
:legendfont,
:grid,
# :surface,
:nlevels,
:levels,
]
supportedAxes(::GadflyPackage) = [:auto, :left]
supportedTypes(::GadflyPackage) = [:none, :line, :path, :steppre, :steppost, :sticks,
@ -154,7 +154,6 @@ supportedArgs(::PyPlotPackage) = [
:legendfont,
:grid,
# :surface,
:nlevels,
:levels,
:fillalpha,
:linealpha,
@ -414,7 +413,7 @@ supportedArgs(::BokehPackage) = [
# :legendfont,
# :grid,
# :surface,
# :nlevels,
# :levels,
]
supportedAxes(::BokehPackage) = [:auto, :left]
supportedTypes(::BokehPackage) = [:none, :path, :scatter] #,:steppre, :steppost, :sticks, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :contour]
@ -480,7 +479,7 @@ supportedArgs(::PlotlyPackage) = [
:guidefont,
:legendfont,
:grid,
:nlevels,
:levels,
]
supportedAxes(::PlotlyPackage) = [:auto, :left]
supportedTypes(::PlotlyPackage) = [:none, :line, :path, :scatter, :steppre, :steppost,
@ -550,7 +549,7 @@ supportedArgs(::GLVisualizePackage) = [
# :legendfont,
# :grid,
# :surface
# :nlevels,
# :levels,
]
supportedAxes(::GLVisualizePackage) = [:auto, :left]
supportedTypes(::GLVisualizePackage) = [:contour] #, :path, :scatter ,:steppre, :steppost, :sticks, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :contour]

View File

@ -190,6 +190,16 @@ end
isijulia() = isdefined(Main, :IJulia) && Main.IJulia.inited
istuple(::Tuple) = true
istuple(::Any) = false
isvector(::AVec) = true
isvector(::Any) = false
ismatrix(::AMat) = true
ismatrix(::Any) = false
isscalar(::Real) = true
isscalar(::Any) = false
# ticksType{T<:Real,S<:Real}(ticks::@compat(Tuple{T,S})) = :limits
ticksType{T<:Real}(ticks::AVec{T}) = :ticks