plotly 3d path/scatter, surface
This commit is contained in:
parent
cdc7920dff
commit
9d4c456461
@ -55,6 +55,10 @@ export
|
|||||||
contour!,
|
contour!,
|
||||||
surface,
|
surface,
|
||||||
surface!,
|
surface!,
|
||||||
|
path3d,
|
||||||
|
path3d!,
|
||||||
|
scatter3d,
|
||||||
|
scatter3d!,
|
||||||
|
|
||||||
title!,
|
title!,
|
||||||
xlabel!,
|
xlabel!,
|
||||||
@ -164,6 +168,10 @@ contour(args...; kw...) = plot(args...; kw..., linetype = :contour)
|
|||||||
contour!(args...; kw...) = plot!(args...; kw..., linetype = :contour)
|
contour!(args...; kw...) = plot!(args...; kw..., linetype = :contour)
|
||||||
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)
|
||||||
|
path3d(args...; kw...) = plot(args...; kw..., linetype = :path3d)
|
||||||
|
path3d!(args...; kw...) = plot!(args...; kw..., linetype = :path3d)
|
||||||
|
scatter3d(args...; kw...) = plot(args...; kw..., linetype = :scatter3d)
|
||||||
|
scatter3d!(args...; kw...) = plot!(args...; kw..., linetype = :scatter3d)
|
||||||
|
|
||||||
|
|
||||||
title!(s::@compat(AbstractString); kw...) = plot!(; title = s, kw...)
|
title!(s::@compat(AbstractString); kw...) = plot!(; title = s, kw...)
|
||||||
|
|||||||
@ -11,7 +11,7 @@ const _3dTypes = [:path3d, :scatter3d]
|
|||||||
const _allTypes = vcat([
|
const _allTypes = vcat([
|
||||||
:none, :line, :path, :steppre, :steppost, :sticks, :scatter,
|
:none, :line, :path, :steppre, :steppost, :sticks, :scatter,
|
||||||
:heatmap, :hexbin, :hist, :density, :bar, :hline, :vline, :ohlc,
|
:heatmap, :hexbin, :hist, :density, :bar, :hline, :vline, :ohlc,
|
||||||
:contour, :pie
|
:contour, :surface, :pie
|
||||||
], _3dTypes)
|
], _3dTypes)
|
||||||
@compat const _typeAliases = Dict(
|
@compat const _typeAliases = Dict(
|
||||||
:n => :none,
|
:n => :none,
|
||||||
@ -31,8 +31,9 @@ const _allTypes = vcat([
|
|||||||
:dots => :scatter,
|
:dots => :scatter,
|
||||||
:histogram => :hist,
|
:histogram => :hist,
|
||||||
:pdf => :density,
|
:pdf => :density,
|
||||||
:contours => :contours,
|
:contours => :contour,
|
||||||
:line3d => :path3d,
|
:line3d => :path3d,
|
||||||
|
:surf => :surface,
|
||||||
)
|
)
|
||||||
|
|
||||||
ishistlike(lt::Symbol) = lt in (:hist, :density)
|
ishistlike(lt::Symbol) = lt in (:hist, :density)
|
||||||
|
|||||||
@ -203,8 +203,9 @@ function get_series_html(d::Dict)
|
|||||||
d_out[:name] = d[:label]
|
d_out[:name] = d[:label]
|
||||||
|
|
||||||
lt = d[:linetype]
|
lt = d[:linetype]
|
||||||
hasmarker = lt == :scatter || d[:markershape] != :none
|
isscatter = lt in (:scatter, :scatter3d)
|
||||||
hasline = lt != :scatter
|
hasmarker = isscatter || d[:markershape] != :none
|
||||||
|
hasline = !isscatter
|
||||||
|
|
||||||
# set the "type"
|
# set the "type"
|
||||||
if lt in (:line, :path, :scatter, :steppre, :steppost)
|
if lt in (:line, :path, :scatter, :steppre, :steppost)
|
||||||
@ -246,14 +247,15 @@ function get_series_html(d::Dict)
|
|||||||
d_out[:histnorm] = "probability density"
|
d_out[:histnorm] = "probability density"
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif lt == :contour
|
elseif lt in (:contour, :surface)
|
||||||
d_out[:type] = "contour"
|
d_out[:type] = string(lt)
|
||||||
d_out[:x], d_out[:y] = x, y
|
d_out[:x], d_out[:y] = x, y
|
||||||
d_out[:z] = d[:z].surf
|
d_out[:z] = d[:z].surf
|
||||||
# d_out[:showscale] = d[:legend]
|
# d_out[:showscale] = d[:legend]
|
||||||
d_out[:ncontours] = d[:nlevels]
|
if lt == :contour
|
||||||
d_out[:contours] = Dict(:coloring => d[:fillrange] != nothing ? "fill" : "lines")
|
d_out[:ncontours] = d[:nlevels]
|
||||||
# TODO: colorscale: [[0, 'rgb(166,206,227)'], [0.25, 'rgb(31,120,180)'], [0.45, 'rgb(178,223,138)'], [0.65, 'rgb(51,160,44)'], [0.85, 'rgb(251,154,153)'], [1, 'rgb(227,26,28)']]
|
d_out[:contours] = Dict(:coloring => d[:fillrange] != nothing ? "fill" : "lines")
|
||||||
|
end
|
||||||
d_out[:colorscale] = plotly_colorscale(d[:linecolor])
|
d_out[:colorscale] = plotly_colorscale(d[:linecolor])
|
||||||
|
|
||||||
elseif lt == :pie
|
elseif lt == :pie
|
||||||
@ -262,6 +264,16 @@ function get_series_html(d::Dict)
|
|||||||
d_out[:values] = y
|
d_out[:values] = y
|
||||||
d_out[:hoverinfo] = "label+percent+name"
|
d_out[:hoverinfo] = "label+percent+name"
|
||||||
|
|
||||||
|
elseif lt in (:path3d, :scatter3d)
|
||||||
|
d_out[:type] = "scatter3d"
|
||||||
|
d_out[:mode] = if hasmarker
|
||||||
|
hasline ? "lines+markers" : "markers"
|
||||||
|
else
|
||||||
|
hasline ? "lines" : "none"
|
||||||
|
end
|
||||||
|
d_out[:x], d_out[:y] = x, y
|
||||||
|
d_out[:z] = collect(d[:z])
|
||||||
|
|
||||||
else
|
else
|
||||||
error("Plotly: linetype $lt isn't supported.")
|
error("Plotly: linetype $lt isn't supported.")
|
||||||
end
|
end
|
||||||
|
|||||||
@ -483,7 +483,8 @@ supportedArgs(::PlotlyPackage) = [
|
|||||||
]
|
]
|
||||||
supportedAxes(::PlotlyPackage) = [:auto, :left]
|
supportedAxes(::PlotlyPackage) = [:auto, :left]
|
||||||
supportedTypes(::PlotlyPackage) = [:none, :path, :scatter, :steppre, :steppost,
|
supportedTypes(::PlotlyPackage) = [:none, :path, :scatter, :steppre, :steppost,
|
||||||
:heatmap, :hist, :density, :bar, :contour, :pie] #,, :sticks, :hexbin, :hline, :vline]
|
:heatmap, :hist, :density, :bar, :contour, :surface, :path3d, :scatter3d,
|
||||||
|
:pie] #,, :sticks, :hexbin, :hline, :vline]
|
||||||
supportedStyles(::PlotlyPackage) = [:auto, :solid, :dash, :dot, :dashdot]
|
supportedStyles(::PlotlyPackage) = [:auto, :solid, :dash, :dot, :dashdot]
|
||||||
supportedMarkers(::PlotlyPackage) = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross,
|
supportedMarkers(::PlotlyPackage) = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross,
|
||||||
:pentagon, :hexagon, :octagon] #vcat(_allMarkers, Shape)
|
:pentagon, :hexagon, :octagon] #vcat(_allMarkers, Shape)
|
||||||
|
|||||||
14
src/plot.jl
14
src/plot.jl
@ -352,9 +352,13 @@ function createKWargsList(plt::PlottingObject, y; kw...)
|
|||||||
createKWargsList(plt, nothing, y; kw...)
|
createKWargsList(plt, nothing, y; kw...)
|
||||||
end
|
end
|
||||||
|
|
||||||
# contours or surfaces... irregular data
|
# 3d line or scatter
|
||||||
function createKWargsList(plt::PlottingObject, x::AVec, y::AVec, zvec::AVec; kw...)
|
function createKWargsList(plt::PlottingObject, x::AVec, y::AVec, zvec::AVec; kw...)
|
||||||
error("TODO: contours or surfaces... irregular data")
|
d = Dict(kw)
|
||||||
|
if !(get(d, :linetype, :none) in _3dTypes)
|
||||||
|
d[:linetype] = :path3d
|
||||||
|
end
|
||||||
|
createKWargsList(plt, x, y; z=zvec, d...)
|
||||||
end
|
end
|
||||||
|
|
||||||
# contours or surfaces... function grid
|
# contours or surfaces... function grid
|
||||||
@ -377,7 +381,11 @@ function createKWargsList{T<:Real}(plt::PlottingObject, x::AVec, y::AVec, zmat::
|
|||||||
surf = Surface(convert(Matrix{Float64}, zmat))
|
surf = Surface(convert(Matrix{Float64}, zmat))
|
||||||
# surf = Array(Any,1,1)
|
# surf = Array(Any,1,1)
|
||||||
# surf[1,1] = convert(Matrix{Float64}, zmat)
|
# surf[1,1] = convert(Matrix{Float64}, zmat)
|
||||||
createKWargsList(plt, x, y; kw..., z = surf, linetype = :contour)
|
d = Dict(kw)
|
||||||
|
if !(get(d, :linetype, :none) in (:contour, :surface))
|
||||||
|
d[:linetype] = :contour
|
||||||
|
end
|
||||||
|
createKWargsList(plt, x, y; d..., z = surf)
|
||||||
end
|
end
|
||||||
|
|
||||||
function createKWargsList(plt::PlottingObject, surf::Surface; kw...)
|
function createKWargsList(plt::PlottingObject, surf::Surface; kw...)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user