Skip to content

Commit bb2964d

Browse files
committed
Fix errors due to new behavior of Zip
1 parent eacdc01 commit bb2964d

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

src/Gadfly.jl

+1-2
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,7 @@ function render_prepared(plot::Plot,
860860
# IV. Geometries
861861
themes = Theme[layer.theme === nothing ? plot.theme : layer.theme
862862
for layer in plot.layers]
863-
864-
zips = zip(plot.layers, layer_aess,
863+
zips = trim_zip(plot.layers, layer_aess,
865864
layer_subplot_aess,
866865
layer_subplot_datas,
867866
themes)

src/geom/boxplot.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function render(geom::BoxplotGeometry, theme::Gadfly.Theme, aes::Gadfly.Aestheti
3434

3535
bw = 1w / n - theme.boxplot_spacing # boxplot width
3636
if length(aes.x) > 1
37-
minspan = minimum([xj - xi for (xi, xj) in zip(aes.x, aes.x[2:end])])
37+
minspan = minimum([xj - xi for (xi, xj) in zip(aes.x[1:end-1], aes.x[2:end])])
3838
bw = minspan*cx - theme.boxplot_spacing
3939
end
4040

src/misc.jl

+15
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,18 @@ function group_color_isless{S, T <: Colorant}(a::(@compat Tuple{S, T}),
433433
return false
434434
end
435435
end
436+
437+
438+
"""
439+
trim longer arrays to the size of the smallest one
440+
and zip the arrays.
441+
"""
442+
function trim_zip(xs...)
443+
mx = max(map(length, xs)...)
444+
mn = min(map(length, xs)...)
445+
if mx == mn
446+
zip(xs...)
447+
else
448+
zip([length(x) == mn ? x : x[1:mn] for x in xs]...)
449+
end
450+
end

src/scale.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ function apply_scale(scale::ContinuousColorScale,
710710
color_key_labels = Dict{Color, AbstractString}()
711711

712712
tick_labels = scale.trans.label(ticks)
713-
for (i, j, label) in zip(ticks, ticks[2:end], tick_labels)
713+
for (i, j, label) in zip(ticks, ticks[2:end], tick_labels[1:end-1])
714714
r = (i - cmin) / cspan
715715
c = scale.f(r)
716716
color_key_colors[c] = r

src/statistics.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ function apply_statistic(stat::BoxplotStatistic,
10771077

10781078
if length(aes.x) > 1 && (haskey(scales, :x) && isa(scales[:x], Scale.ContinuousScale))
10791079
xmin, xmax = minimum(aes.x), maximum(aes.x)
1080-
minspan = minimum([xj - xi for (xi, xj) in zip(aes.x, aes.x[2:end])])
1080+
minspan = minimum([xj - xi for (xi, xj) in zip(aes.x[1:end-1], aes.x[2:end])])
10811081

10821082
xviewmin = xmin - minspan / 2
10831083
xviewmax = xmax + minspan / 2

0 commit comments

Comments
 (0)