pyplot 3d line segments

This commit is contained in:
Thomas Breloff 2016-06-15 02:15:51 -04:00
parent c8ed611c9c
commit 2bd67f3519

View File

@ -64,6 +64,7 @@ function _initialize_backend(::PyPlotBackend)
const pynp = PyPlot.pywrap(PyPlot.pyimport("numpy")) const pynp = PyPlot.pywrap(PyPlot.pyimport("numpy"))
const pytransforms = PyPlot.pywrap(PyPlot.pyimport("matplotlib.transforms")) const pytransforms = PyPlot.pywrap(PyPlot.pyimport("matplotlib.transforms"))
const pycollections = PyPlot.pywrap(PyPlot.pyimport("matplotlib.collections")) const pycollections = PyPlot.pywrap(PyPlot.pyimport("matplotlib.collections"))
const pyart3d = PyPlot.pywrap(PyPlot.pyimport("mpl_toolkits.mplot3d.art3d"))
end end
# we don't want every command to update the figure # we don't want every command to update the figure
@ -429,18 +430,28 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
# multicolored line segments # multicolored line segments
n = length(x) - 1 n = length(x) - 1
segments = Array(Any,n) segments = Array(Any,n)
for i=1:n kw = KW(
segments[i] = [(cycle(x,i), cycle(y,i)), (cycle(x,i+1), cycle(y,i+1))] :label => d[:label],
end :zorder => plt.n,
lc = pycollections.LineCollection(segments; :cmap => py_linecolormap(d),
label = d[:label], :linewidth => d[:linewidth],
zorder = plt.n, :linestyle => py_linestyle(st, d[:linestyle])
cmap = py_linecolormap(d),
linewidth = d[:linewidth],
linestyle = py_linestyle(st, d[:linestyle])
) )
lc[:set_array](d[:line_z]) handle = if is3d(st)
handle = ax[:add_collection](lc) 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[:set_array](d[:line_z])
ax[:add_collection3d](lc, zs=z) #, zdir='y')
else
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[:set_array](d[:line_z])
ax[:add_collection](lc)
end
push!(handles, handle) push!(handles, handle)
needs_colorbar = true needs_colorbar = true
end end