Skip to content

Commit 04a7d26

Browse files
BeastyBlacksmithisentropic
authored andcommitted
Fix fillranges with OffsetVectors for plotly (JuliaPlots#4006)
* don't mutate the Plot object * remove show * collect vectors to workaround vcat issue
1 parent 15e6910 commit 04a7d26

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/backends/plotly.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,15 +940,15 @@ function plotly_series_segments(series::Series, plotattributes_base::KW, x, y, z
940940
plotattributes_out_fillrange[:showlegend] = false
941941
# if fillrange is provided as real or tuple of real, expand to array
942942
if typeof(series[:fillrange]) <: Real
943-
series[:fillrange] = fill(series[:fillrange], length(rng))
943+
plotattributes_out[:fillrange] = fill(series[:fillrange], length(rng))
944944
elseif typeof(series[:fillrange]) <: Tuple
945945
f1 =
946946
typeof(series[:fillrange][1]) <: Real ?
947947
fill(series[:fillrange][1], length(rng)) : series[:fillrange][1][rng]
948948
f2 =
949949
typeof(series[:fillrange][2]) <: Real ?
950950
fill(series[:fillrange][2], length(rng)) : series[:fillrange][2][rng]
951-
series[:fillrange] = (f1, f2)
951+
plotattributes_out[:fillrange] = (f1, f2)
952952
end
953953
if isa(series[:fillrange], AbstractVector)
954954
plotattributes_out_fillrange[:y] = series[:fillrange][rng]

src/examples.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -962,9 +962,9 @@ const _examples = PlotExample[
962962
"""
963963
Allows to plot arbitrary 3d meshes. If only x,y,z are given the mesh is generated automatically.
964964
You can also specify the connections using the connections keyword.
965-
The connections can be specified in two ways: Either as a tuple of vectors where each vector
966-
contains the 0-based indices of one point of a triangle, such that elements at the same
967-
position of these vectors form a triangle. Or as a vector of NTuple{3,Ints} where each element
965+
The connections can be specified in two ways: Either as a tuple of vectors where each vector
966+
contains the 0-based indices of one point of a triangle, such that elements at the same
967+
position of these vectors form a triangle. Or as a vector of NTuple{3,Ints} where each element
968968
contains the 1-based indices of the three points of a triangle.
969969
""",
970970
[
@@ -1235,7 +1235,7 @@ const _examples = PlotExample[
12351235
PlotExample( # 56
12361236
"Bar plot customizations",
12371237
"""
1238-
Width of bars may be specified as `bar_width`.
1238+
Width of bars may be specified as `bar_width`.
12391239
The bars' baseline may be specified as `fillto`.
12401240
Each may be scalar, or a vector spcifying one value per bar.
12411241
""",
@@ -1271,7 +1271,7 @@ _animation_examples = [2, 31]
12711271
_backend_skips = Dict(
12721272
:gr => [25, 30],
12731273
:pyplot => [2, 25, 30, 31, 49, 55, 56],
1274-
:plotlyjs => [2, 21, 24, 25, 30, 31, 49, 51, 55, 56],
1274+
:plotlyjs => [2, 21, 24, 25, 30, 31, 49, 50, 51, 55, 56],
12751275
:pgfplotsx => [
12761276
2, # animation
12771277
6, # images

src/utils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@ end
434434

435435
#turn tuple of fillranges to one path
436436
function concatenate_fillrange(x, y::Tuple)
437-
rib1, rib2 = first(y), last(y)
438-
yline = vcat(rib1, (rib2)[end:-1:1])
439-
xline = vcat(x, x[end:-1:1])
437+
rib1, rib2 = collect(first(y)), collect(last(y)) # collect needed until https://github.com/JuliaLang/julia/pull/37629 is merged
438+
yline = vcat(rib1, reverse(rib2))
439+
xline = vcat(x, reverse(x))
440440
return xline, yline
441441
end
442442

0 commit comments

Comments
 (0)