fix pyplot (leave commented lines for possible future work)

This commit is contained in:
Daniel Schwabeneder 2018-04-02 23:21:57 +02:00
parent 777642ef55
commit a6f11cdb31

View File

@ -495,35 +495,36 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
if st in (:path, :path3d, :steppre, :steppost, :straightline) if st in (:path, :path3d, :steppre, :steppost, :straightline)
if maximum(series[:linewidth]) > 0 if maximum(series[:linewidth]) > 0
segments = iter_segments(series) segments = iter_segments(series)
if length(segments) > 1 && (!any(typeof(series[attr]) <: AbstractVector for attr in (:fillcolor, :fillalpha)) || series[:fill_z] != nothing) && !(typeof(series[:linestyle]) <: AbstractVector) # TODO: check LineCollection alternative for speed
# multicolored line segments # if length(segments) > 1 && (any(typeof(series[attr]) <: AbstractVector for attr in (:fillcolor, :fillalpha)) || series[:fill_z] != nothing) && !(typeof(series[:linestyle]) <: AbstractVector)
n = length(segments) # # multicolored line segments
# segments = Array(Any,n) # n = length(segments)
segments = [] # # segments = Array(Any,n)
kw = KW( # segments = []
:label => series[:label], # kw = KW(
:zorder => plt.n, # :label => series[:label],
:cmap => py_linecolormap(series), # :zorder => plt.n,
:linewidths => py_dpi_scale(plt, get_linewidth.(series, 1:n)), # :cmap => py_linecolormap(series),
:linestyle => py_linestyle(st, get_linestyle.(series)), # :linewidths => py_dpi_scale(plt, get_linewidth.(series, 1:n)),
:norm => pycolors["Normalize"](; extrakw...) # :linestyle => py_linestyle(st, get_linestyle.(series)),
) # :norm => pycolors["Normalize"](; extrakw...)
lz = _cycle(series[:line_z], 1:n) # )
handle = if is3d(st) # lz = _cycle(series[:line_z], 1:n)
line_segments = [[(x[j], y[j], z[j]) for j in rng] for rng in segments] # handle = if is3d(st)
lc = pyart3d["Line3DCollection"](line_segments; kw...) # line_segments = [[(x[j], y[j], z[j]) for j in rng] for rng in segments]
lc[:set_array](lz) # lc = pyart3d["Line3DCollection"](line_segments; kw...)
ax[:add_collection3d](lc, zs=z) #, zdir='y') # lc[:set_array](lz)
lc # ax[:add_collection3d](lc, zs=z) #, zdir='y')
else # lc
line_segments = [[(x[j], y[j]) for j in rng] for rng in segments] # else
lc = pycollections["LineCollection"](line_segments; kw...) # line_segments = [[(x[j], y[j]) for j in rng] for rng in segments]
lc[:set_array](lz) # lc = pycollections["LineCollection"](line_segments; kw...)
ax[:add_collection](lc) # lc[:set_array](lz)
lc # ax[:add_collection](lc)
end # lc
push!(handles, handle) # end
else # push!(handles, handle)
# else
for (i, rng) in enumerate(iter_segments(series)) for (i, rng) in enumerate(iter_segments(series))
handle = ax[:plot]((arg[rng] for arg in xyargs)...; handle = ax[:plot]((arg[rng] for arg in xyargs)...;
label = i == 1 ? series[:label] : "", label = i == 1 ? series[:label] : "",
@ -536,7 +537,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
)[1] )[1]
push!(handles, handle) push!(handles, handle)
end end
end # end
a = series[:arrow] a = series[:arrow]
if a != nothing && !is3d(st) # TODO: handle 3d later if a != nothing && !is3d(st) # TODO: handle 3d later