contour3d

This commit is contained in:
Thomas Breloff 2016-04-26 14:35:51 -04:00
parent b9d20142a2
commit 8b569e3cd8
4 changed files with 27 additions and 13 deletions

View File

@ -60,6 +60,8 @@ export
pie!, pie!,
contour, contour,
contour!, contour!,
contour3d,
contour3d!,
surface, surface,
surface!, surface!,
wireframe, wireframe,
@ -191,6 +193,8 @@ pie(args...; kw...) = plot(args...; kw..., linetype = :pie)
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)
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)
surface!(args...; kw...) = plot!(args...; kw..., linetype = :surface) surface!(args...; kw...) = plot!(args...; kw..., linetype = :surface)
wireframe(args...; kw...) = plot(args...; kw..., linetype = :wireframe) wireframe(args...; kw...) = plot(args...; kw..., linetype = :wireframe)

View File

@ -7,11 +7,11 @@ const _allAxes = [:auto, :left, :right]
:r => :right :r => :right
) )
const _3dTypes = [:path3d, :scatter3d, :surface, :wireframe] const _3dTypes = [:path3d, :scatter3d, :surface, :wireframe, :contour3d]
const _allTypes = vcat([ const _allTypes = vcat([
:none, :line, :path, :steppre, :steppost, :sticks, :scatter, :none, :line, :path, :steppre, :steppost, :sticks, :scatter,
:heatmap, :hexbin, :hist, :hist2d, :hist3d, :density, :bar, :hline, :vline, :ohlc, :heatmap, :hexbin, :hist, :hist2d, :hist3d, :density, :bar, :hline, :vline, :ohlc,
:contour, :pie, :shape, :box, :violin, :quiver :contour, :contour3d, :pie, :shape, :box, :violin, :quiver
], _3dTypes) ], _3dTypes)
@compat const _typeAliases = KW( @compat const _typeAliases = KW(
:n => :none, :n => :none,
@ -45,7 +45,7 @@ const _allTypes = vcat([
like_histogram(linetype::Symbol) = linetype in (:hist, :density) like_histogram(linetype::Symbol) = linetype in (:hist, :density)
like_line(linetype::Symbol) = linetype in (:line, :path, :steppre, :steppost) 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] const _allStyles = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]

View File

@ -455,7 +455,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
end end
end end
if lt == :contour if lt in (:contour, :contour3d)
z = z.surf' z = z.surf'
needs_colorbar = true 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") error("Only numbers and vectors are supported with levels keyword")
end end
if lt == :contour3d
extrakw[:extend3d] = true
end
# contour lines # contour lines
handle = ax[:contour](x, y, z, args...; handle = ax[:contour](x, y, z, args...;
label = d[:label], label = d[:label],
@ -482,13 +486,15 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
push!(handles, handle) push!(handles, handle)
# contour fills # contour fills
handle = ax[:contourf](x, y, z, args...; if lt == :contour
label = d[:label], handle = ax[:contourf](x, y, z, args...;
zorder = plt.n + 0.5, label = d[:label],
cmap = pyfillcolormap(d), zorder = plt.n + 0.5,
extrakw... cmap = pyfillcolormap(d),
) extrakw...
push!(handles, handle) )
push!(handles, handle)
end
end end
if lt in (:surface, :wireframe) if lt in (:surface, :wireframe)
@ -914,7 +920,11 @@ function addPyPlotLegend(plt::Plot, ax)
leg = plt.plotargs[:legend] leg = plt.plotargs[:legend]
if leg != :none if leg != :none
# gotta do this to ensure both axes are included # 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) args = filter(x -> x[:label] != "", args)
if length(args) > 0 if length(args) > 0
leg = ax[:legend]([d[:serieshandle][1] for d in args], leg = ax[:legend]([d[:serieshandle][1] for d in args],

View File

@ -112,7 +112,7 @@ supportedTypes(::PyPlotBackend) = [
:scatter, :hist2d, :hexbin, :hist, :density, :scatter, :hist2d, :hexbin, :hist, :density,
:bar, :sticks, :box, :violin, :quiver, :bar, :sticks, :box, :violin, :quiver,
:hline, :vline, :heatmap, :hline, :vline, :heatmap,
:contour, :path3d, :scatter3d, :surface, :wireframe :contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe
] ]
supportedStyles(::PyPlotBackend) = [:auto, :solid, :dash, :dot, :dashdot] supportedStyles(::PyPlotBackend) = [:auto, :solid, :dash, :dot, :dashdot]
supportedMarkers(::PyPlotBackend) = vcat(_allMarkers, Shape) supportedMarkers(::PyPlotBackend) = vcat(_allMarkers, Shape)