fix for discrete bars; closes #365
This commit is contained in:
parent
d5e9340f8f
commit
aec162c50e
@ -402,15 +402,11 @@ end
|
|||||||
error("bar recipe: x must be same length as y (centers), or one more than y (edges).\n\t\tlength(x)=$(length(x)), length(y)=$(length(y))")
|
error("bar recipe: x must be same length as y (centers), or one more than y (edges).\n\t\tlength(x)=$(length(x)), length(y)=$(length(y))")
|
||||||
end
|
end
|
||||||
|
|
||||||
# # if horizontal, switch x/y
|
axis = d[:subplot][isvertical(d) ? :xaxis : :yaxis]
|
||||||
# if !isvertical(d)
|
|
||||||
# x, y = y, x
|
|
||||||
# # nx, ny = ny, nx
|
|
||||||
# end
|
|
||||||
|
|
||||||
bw = d[:bar_width]
|
bw = d[:bar_width]
|
||||||
hw = if bw == nothing
|
hw = if bw == nothing
|
||||||
0.5mean(diff(x))
|
# 0.5mean(diff(x))
|
||||||
|
0.5mean(diff([discrete_value!(axis, xi)[1] for xi=x]))
|
||||||
else
|
else
|
||||||
Float64[0.5cycle(bw,i) for i=1:length(x)]
|
Float64[0.5cycle(bw,i) for i=1:length(x)]
|
||||||
end
|
end
|
||||||
@ -424,11 +420,12 @@ end
|
|||||||
# create the bar shapes by adding x/y segments
|
# create the bar shapes by adding x/y segments
|
||||||
xseg, yseg = Segments(), Segments()
|
xseg, yseg = Segments(), Segments()
|
||||||
for i=1:ny
|
for i=1:ny
|
||||||
ci = x[i]
|
# ci = x[i]
|
||||||
|
center = discrete_value!(axis, x[i])[1]
|
||||||
hwi = cycle(hw,i)
|
hwi = cycle(hw,i)
|
||||||
yi = y[i]
|
yi = y[i]
|
||||||
fi = cycle(fillto,i)
|
fi = cycle(fillto,i)
|
||||||
push!(xseg, ci-hwi, ci-hwi, ci+hwi, ci+hwi, ci-hwi)
|
push!(xseg, center-hwi, center-hwi, center+hwi, center+hwi, center-hwi)
|
||||||
push!(yseg, yi, fi, fi, yi, yi)
|
push!(yseg, yi, fi, fi, yi, yi)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user