From 04a7d26b149e09183a165e31b944578209f7f2f4 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Mon, 20 Dec 2021 21:24:58 +0100 Subject: [PATCH] Fix fillranges with OffsetVectors for plotly (#4006) * don't mutate the Plot object * remove show * collect vectors to workaround vcat issue --- src/backends/plotly.jl | 4 ++-- src/examples.jl | 10 +++++----- src/utils.jl | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index eb5f2692..94073d00 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -940,7 +940,7 @@ function plotly_series_segments(series::Series, plotattributes_base::KW, x, y, z plotattributes_out_fillrange[:showlegend] = false # if fillrange is provided as real or tuple of real, expand to array if typeof(series[:fillrange]) <: Real - series[:fillrange] = fill(series[:fillrange], length(rng)) + plotattributes_out[:fillrange] = fill(series[:fillrange], length(rng)) elseif typeof(series[:fillrange]) <: Tuple f1 = typeof(series[:fillrange][1]) <: Real ? @@ -948,7 +948,7 @@ function plotly_series_segments(series::Series, plotattributes_base::KW, x, y, z f2 = typeof(series[:fillrange][2]) <: Real ? fill(series[:fillrange][2], length(rng)) : series[:fillrange][2][rng] - series[:fillrange] = (f1, f2) + plotattributes_out[:fillrange] = (f1, f2) end if isa(series[:fillrange], AbstractVector) plotattributes_out_fillrange[:y] = series[:fillrange][rng] diff --git a/src/examples.jl b/src/examples.jl index c173f328..0c56bce9 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -962,9 +962,9 @@ const _examples = PlotExample[ """ Allows to plot arbitrary 3d meshes. If only x,y,z are given the mesh is generated automatically. You can also specify the connections using the connections keyword. - The connections can be specified in two ways: Either as a tuple of vectors where each vector - contains the 0-based indices of one point of a triangle, such that elements at the same - position of these vectors form a triangle. Or as a vector of NTuple{3,Ints} where each element + The connections can be specified in two ways: Either as a tuple of vectors where each vector + contains the 0-based indices of one point of a triangle, such that elements at the same + position of these vectors form a triangle. Or as a vector of NTuple{3,Ints} where each element contains the 1-based indices of the three points of a triangle. """, [ @@ -1235,7 +1235,7 @@ const _examples = PlotExample[ PlotExample( # 56 "Bar plot customizations", """ - Width of bars may be specified as `bar_width`. + Width of bars may be specified as `bar_width`. The bars' baseline may be specified as `fillto`. Each may be scalar, or a vector spcifying one value per bar. """, @@ -1271,7 +1271,7 @@ _animation_examples = [2, 31] _backend_skips = Dict( :gr => [25, 30], :pyplot => [2, 25, 30, 31, 49, 55, 56], - :plotlyjs => [2, 21, 24, 25, 30, 31, 49, 51, 55, 56], + :plotlyjs => [2, 21, 24, 25, 30, 31, 49, 50, 51, 55, 56], :pgfplotsx => [ 2, # animation 6, # images diff --git a/src/utils.jl b/src/utils.jl index 866ff1d6..b0ed9e60 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -434,9 +434,9 @@ end #turn tuple of fillranges to one path function concatenate_fillrange(x, y::Tuple) - rib1, rib2 = first(y), last(y) - yline = vcat(rib1, (rib2)[end:-1:1]) - xline = vcat(x, x[end:-1:1]) + rib1, rib2 = collect(first(y)), collect(last(y)) # collect needed until https://github.com/JuliaLang/julia/pull/37629 is merged + yline = vcat(rib1, reverse(rib2)) + xline = vcat(x, reverse(x)) return xline, yline end