pyplot line segments fix; bar fixes
This commit is contained in:
parent
ec06a01b6c
commit
71b48427c5
@ -436,7 +436,8 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
else
|
else
|
||||||
# multicolored line segments
|
# multicolored line segments
|
||||||
n = length(x) - 1
|
n = length(x) - 1
|
||||||
segments = Array(Any,n)
|
# segments = Array(Any,n)
|
||||||
|
segments = []
|
||||||
kw = KW(
|
kw = KW(
|
||||||
:label => series[:label],
|
:label => series[:label],
|
||||||
:zorder => plt.n,
|
:zorder => plt.n,
|
||||||
@ -445,17 +446,23 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
:linestyle => py_linestyle(st, series[:linestyle])
|
:linestyle => py_linestyle(st, series[:linestyle])
|
||||||
)
|
)
|
||||||
handle = if is3d(st)
|
handle = if is3d(st)
|
||||||
for i=1:n
|
for rng in iter_segments(x, y, z)
|
||||||
segments[i] = [(cycle(x,i), cycle(y,i), cycle(z,i)), (cycle(x,i+1), cycle(y,i+1), cycle(z,i+1))]
|
push!(segments, [(cycle(x,i),cycle(y,i),cycle(z,i)) for i in rng])
|
||||||
end
|
end
|
||||||
|
# for i=1:n
|
||||||
|
# segments[i] = [(cycle(x,i), cycle(y,i), cycle(z,i)), (cycle(x,i+1), cycle(y,i+1), cycle(z,i+1))]
|
||||||
|
# end
|
||||||
lc = pyart3d.Line3DCollection(segments; kw...)
|
lc = pyart3d.Line3DCollection(segments; kw...)
|
||||||
lc[:set_array](series[:line_z])
|
lc[:set_array](series[:line_z])
|
||||||
ax[:add_collection3d](lc, zs=z) #, zdir='y')
|
ax[:add_collection3d](lc, zs=z) #, zdir='y')
|
||||||
lc
|
lc
|
||||||
else
|
else
|
||||||
for i=1:n
|
for rng in iter_segments(x, y)
|
||||||
segments[i] = [(cycle(x,i), cycle(y,i)), (cycle(x,i+1), cycle(y,i+1))]
|
push!(segments, [(cycle(x,i),cycle(y,i)) for i in rng])
|
||||||
end
|
end
|
||||||
|
# for i=1:n
|
||||||
|
# segments[i] = [(cycle(x,i), cycle(y,i)), (cycle(x,i+1), cycle(y,i+1))]
|
||||||
|
# end
|
||||||
lc = pycollections.LineCollection(segments; kw...)
|
lc = pycollections.LineCollection(segments; kw...)
|
||||||
lc[:set_array](series[:line_z])
|
lc[:set_array](series[:line_z])
|
||||||
ax[:add_collection](lc)
|
ax[:add_collection](lc)
|
||||||
|
|||||||
@ -394,18 +394,20 @@ end
|
|||||||
# create a bar plot as a filled step function
|
# create a bar plot as a filled step function
|
||||||
@recipe function f(::Type{Val{:bar}}, x, y, z)
|
@recipe function f(::Type{Val{:bar}}, x, y, z)
|
||||||
nx, ny = length(x), length(y)
|
nx, ny = length(x), length(y)
|
||||||
|
axis = d[:subplot][isvertical(d) ? :xaxis : :yaxis]
|
||||||
|
cv = [discrete_value!(axis, xi)[1] for xi=x]
|
||||||
x = if nx == ny
|
x = if nx == ny
|
||||||
x
|
cv
|
||||||
elseif nx == ny + 1
|
elseif nx == ny + 1
|
||||||
diff(x) + x[1:end-1]
|
0.5diff(cv) + cv[1:end-1]
|
||||||
else
|
else
|
||||||
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
|
||||||
|
|
||||||
axis = d[:subplot][isvertical(d) ? :xaxis : :yaxis]
|
# compute half-width of bars
|
||||||
bw = d[:bar_width]
|
bw = d[:bar_width]
|
||||||
hw = if bw == nothing
|
hw = if bw == nothing
|
||||||
0.5mean(diff([discrete_value!(axis, xi)[1] for xi=x]))
|
0.5mean(diff(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
|
||||||
@ -419,7 +421,7 @@ 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
|
||||||
center = discrete_value!(axis, x[i])[1]
|
center = x[i]
|
||||||
hwi = cycle(hw,i)
|
hwi = cycle(hw,i)
|
||||||
yi = y[i]
|
yi = y[i]
|
||||||
fi = cycle(fillto,i)
|
fi = cycle(fillto,i)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user