Make Plots backends aware of new :stepmid option

This commit is contained in:
David MacMahon 2021-03-24 23:25:57 -07:00
parent ddf6aa9760
commit c2cb60ff12
4 changed files with 11 additions and 5 deletions

View File

@ -555,6 +555,7 @@ const _pyplot_attr = merge_with_base_supported([
const _pyplot_seriestype = [
:path,
:steppre,
:stepmid,
:steppost,
:shape,
:straightline,
@ -636,6 +637,7 @@ const _hdf5_attr = merge_with_base_supported([
const _hdf5_seriestype = [
:path,
:steppre,
:stepmid,
:steppost,
:shape,
:straightline,
@ -707,7 +709,7 @@ const _inspectdr_attr = merge_with_base_supported([
])
const _inspectdr_style = [:auto, :solid, :dash, :dot, :dashdot]
const _inspectdr_seriestype = [
:path, :scatter, :shape, :straightline, #, :steppre, :steppost
:path, :scatter, :shape, :straightline, #, :steppre, :stepmid, :steppost
]
#see: _allMarkers, _shape_keys
const _inspectdr_marker = Symbol[

View File

@ -290,7 +290,7 @@ For st in :shape:
color = linecolor, fillcolor = fillcolor
)
end
elseif st in (:path, :scatter, :straightline) #, :steppre, :steppost)
elseif st in (:path, :scatter, :straightline) #, :steppre, :stepmid, :steppost)
#NOTE: In Plots.jl, :scatter plots have 0-linewidths (I think).
linewidth = series[:linewidth]
#More efficient & allows some support for markerstrokewidth:

View File

@ -789,6 +789,8 @@ function plotly_series_segments(series::Series, plotattributes_base::KW, x, y, z
:width => get_linewidth(series, i),
:shape => if st == :steppre
"vh"
elseif st == :stepmid
"hvh"
elseif st == :steppost
"hv"
else

View File

@ -152,12 +152,14 @@ end
function py_stepstyle(seriestype::Symbol)
seriestype == :steppost && return "steps-post"
seriestype == :stepmid && return "steps-mid"
seriestype == :steppre && return "steps-pre"
return "default"
end
function py_fillstepstyle(seriestype::Symbol)
seriestype == :steppost && return "post"
seriestype == :stepmid && return "mid"
seriestype == :steppre && return "pre"
return nothing
end
@ -408,7 +410,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
# for each plotting command, optionally build and add a series handle to the list
# line plot
if st in (:path, :path3d, :steppre, :steppost, :straightline)
if st in (:path, :path3d, :steppre, :stepmid, :steppost, :straightline)
if maximum(series[:linewidth]) > 0
# TODO: check LineCollection alternative for speed
# if length(segments) > 1 && (any(typeof(series[attr]) <: AbstractVector for attr in (:fillcolor, :fillalpha)) || series[:fill_z] !== nothing) && !(typeof(series[:linestyle]) <: AbstractVector)
@ -485,7 +487,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
# add markers?
if series[:markershape] != :none && st in (
:path, :scatter, :path3d, :scatter3d, :steppre, :steppost, :bar
:path, :scatter, :path3d, :scatter3d, :steppre, :stepmid, :steppost, :bar
)
for segment in series_segments(series, :scatter)
i, rng = segment.attr_index, segment.range
@ -1363,7 +1365,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
linestyle = py_linestyle(series[:seriestype], get_linestyle(series)),
capstyle = "butt"
)
elseif series[:seriestype] in (:path, :straightline, :scatter, :steppre, :steppost)
elseif series[:seriestype] in (:path, :straightline, :scatter, :steppre, :stepmid, :steppost)
hasline = get_linewidth(series) > 0
PyPlot.plt."Line2D"((0, 1),(0,0),
color = py_color(single_color(get_linecolor(series, clims)), get_linealpha(series)),