From e594e22c681196aab109fd80f3636dfe9330c1c9 Mon Sep 17 00:00:00 2001 From: Adrian Dawid Date: Thu, 13 Aug 2020 21:03:01 +0200 Subject: [PATCH] Change i,j,k to series keyword --- src/args.jl | 1 + src/backends/plotly.jl | 18 +++++++++++++----- src/pipeline.jl | 3 +-- src/recipes.jl | 1 - 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/args.jl b/src/args.jl index 6d54c245..1a96bf96 100644 --- a/src/args.jl +++ b/src/args.jl @@ -288,6 +288,7 @@ const _series_defaults = KW( # one logical series to be broken up (path and markers, for example) :hover => nothing, # text to display when hovering over the data points :stride => (1,1), # array stride for wireframe/surface, the first element is the row stride and the second is the column stride. + :connections => nothing, # tuple of arrays to specifiy connectivity of a 3d mesh :extra_kwargs => Dict() ) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 6d2eb55a..c7cf49ae 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -574,11 +574,19 @@ function plotly_series(plt::Plot, series::Series) elseif st == :mesh3d plotattributes_out[:type] = "mesh3d" plotattributes_out[:x], plotattributes_out[:y], plotattributes_out[:z] = x, y, z - - if :i in keys(series[:extra_kwargs]) && :j in keys(series[:extra_kwargs]) && :k in keys(series[:extra_kwargs]) - plotattributes_out[:i] = series[:extra_kwargs][:i] - plotattributes_out[:j] = series[:extra_kwargs][:j] - plotattributes_out[:k] = series[:extra_kwargs][:k] + + if series[:connections] != nothing + if typeof(series[:connections]) <: Tuple{Array,Array,Array} + i,j,k = series[:connections] + if length(i) == length(j) == length(k) + throw(ArgumentError("Argument connections must consist of equally sized arrays.")) + end + plotattributes_out[:i] = i + plotattributes_out[:j] = j + plotattributes_out[:k] = k + else + throw(ArgumentError("Argument connections has to be a tuple of three arrays.")) + end end plotattributes_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha]) diff --git a/src/pipeline.jl b/src/pipeline.jl index 88dcf9a8..bc144cc8 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -331,8 +331,7 @@ function _override_seriestype_check(plotattributes::AKW, st::Symbol) if !RecipesPipeline.is3d(st) && !(st in (:contour, :contour3d)) z = plotattributes[:z] if !isa(z, Nothing) && - (size(plotattributes[:x]) == size(plotattributes[:y]) == size(z)) && - st !== :mesh3d + (size(plotattributes[:x]) == size(plotattributes[:y]) == size(z)) st = (st == :scatter ? :scatter3d : :path3d) plotattributes[:seriestype] = st end diff --git a/src/recipes.jl b/src/recipes.jl index 595c5269..89b98eb2 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -1547,4 +1547,3 @@ julia> areaplot(1:3, [1 2 3; 7 8 9; 4 5 6], seriescolor = [:red :green :blue], f end end -is_3d(::Type{Val{:mesh3d}}) = true