From 8b569e3cd850aa143ae560cd4d856f4555e71e7e Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Tue, 26 Apr 2016 14:35:51 -0400 Subject: [PATCH] contour3d --- src/Plots.jl | 4 ++++ src/args.jl | 6 +++--- src/backends/pyplot.jl | 28 +++++++++++++++++++--------- src/backends/supported.jl | 2 +- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/Plots.jl b/src/Plots.jl index 9e5b3cd1..9fe92f32 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -60,6 +60,8 @@ export pie!, contour, contour!, + contour3d, + contour3d!, surface, surface!, wireframe, @@ -191,6 +193,8 @@ pie(args...; kw...) = plot(args...; kw..., linetype = :pie) pie!(args...; kw...) = plot!(args...; kw..., linetype = :pie) contour(args...; kw...) = plot(args...; kw..., linetype = :contour) contour!(args...; kw...) = plot!(args...; kw..., linetype = :contour) +contour3d(args...; kw...) = plot(args...; kw..., linetype = :contour3d) +contour3d!(args...; kw...) = plot!(args...; kw..., linetype = :contour3d) surface(args...; kw...) = plot(args...; kw..., linetype = :surface) surface!(args...; kw...) = plot!(args...; kw..., linetype = :surface) wireframe(args...; kw...) = plot(args...; kw..., linetype = :wireframe) diff --git a/src/args.jl b/src/args.jl index ca84ac53..3f42f094 100644 --- a/src/args.jl +++ b/src/args.jl @@ -7,11 +7,11 @@ const _allAxes = [:auto, :left, :right] :r => :right ) -const _3dTypes = [:path3d, :scatter3d, :surface, :wireframe] +const _3dTypes = [:path3d, :scatter3d, :surface, :wireframe, :contour3d] const _allTypes = vcat([ :none, :line, :path, :steppre, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :hist2d, :hist3d, :density, :bar, :hline, :vline, :ohlc, - :contour, :pie, :shape, :box, :violin, :quiver + :contour, :contour3d, :pie, :shape, :box, :violin, :quiver ], _3dTypes) @compat const _typeAliases = KW( :n => :none, @@ -45,7 +45,7 @@ const _allTypes = vcat([ like_histogram(linetype::Symbol) = linetype in (:hist, :density) like_line(linetype::Symbol) = linetype in (:line, :path, :steppre, :steppost) -like_surface(linetype::Symbol) = linetype in (:contour, :heatmap, :surface, :wireframe) +like_surface(linetype::Symbol) = linetype in (:contour, :contour3d, :heatmap, :surface, :wireframe) const _allStyles = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot] diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index fc74d01f..11bd781b 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -455,7 +455,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) end end - if lt == :contour + if lt in (:contour, :contour3d) z = z.surf' needs_colorbar = true @@ -470,6 +470,10 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) error("Only numbers and vectors are supported with levels keyword") end + if lt == :contour3d + extrakw[:extend3d] = true + end + # contour lines handle = ax[:contour](x, y, z, args...; label = d[:label], @@ -482,13 +486,15 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) push!(handles, handle) # contour fills - handle = ax[:contourf](x, y, z, args...; - label = d[:label], - zorder = plt.n + 0.5, - cmap = pyfillcolormap(d), - extrakw... - ) - push!(handles, handle) + if lt == :contour + handle = ax[:contourf](x, y, z, args...; + label = d[:label], + zorder = plt.n + 0.5, + cmap = pyfillcolormap(d), + extrakw... + ) + push!(handles, handle) + end end if lt in (:surface, :wireframe) @@ -914,7 +920,11 @@ function addPyPlotLegend(plt::Plot, ax) leg = plt.plotargs[:legend] if leg != :none # gotta do this to ensure both axes are included - args = filter(x -> !(x[:linetype] in (:hist,:density,:hexbin,:hist2d,:hline,:vline,:contour,:surface,:wireframe,:heatmap,:path3d,:scatter3d)), plt.seriesargs) + args = filter(x -> !(x[:linetype] in ( + :hist,:density,:hexbin,:hist2d,:hline,:vline, + :contour,:contour3d,:surface,:wireframe, + :heatmap,:path3d,:scatter3d + )), plt.seriesargs) args = filter(x -> x[:label] != "", args) if length(args) > 0 leg = ax[:legend]([d[:serieshandle][1] for d in args], diff --git a/src/backends/supported.jl b/src/backends/supported.jl index ab261166..b1c17bc4 100644 --- a/src/backends/supported.jl +++ b/src/backends/supported.jl @@ -112,7 +112,7 @@ supportedTypes(::PyPlotBackend) = [ :scatter, :hist2d, :hexbin, :hist, :density, :bar, :sticks, :box, :violin, :quiver, :hline, :vline, :heatmap, - :contour, :path3d, :scatter3d, :surface, :wireframe + :contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe ] supportedStyles(::PyPlotBackend) = [:auto, :solid, :dash, :dot, :dashdot] supportedMarkers(::PyPlotBackend) = vcat(_allMarkers, Shape)