UnicodePlots: support markers (#3845)

This commit is contained in:
t-bltg 2021-09-25 12:18:41 +02:00 committed by GitHub
parent 8d95333d1e
commit 032c5d1638
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 4 deletions

View File

@ -943,7 +943,34 @@ const _unicodeplots_seriestype = [
:spy, :spy,
] ]
const _unicodeplots_style = [:auto, :solid] const _unicodeplots_style = [:auto, :solid]
const _unicodeplots_marker = [:none, :auto, :circle] const _unicodeplots_marker = [
:none,
:auto,
:pixel,
# vvvvvvvvvv shapes
:circle,
:rect,
:star5,
:diamond,
:hexagon,
:cross,
:xcross,
:utriangle,
:dtriangle,
:rtriangle,
:ltriangle,
:pentagon,
# :heptagon,
# :octagon,
:star4,
:star6,
# :star7,
:star8,
:vline,
:hline,
:+,
:x,
]
const _unicodeplots_scale = [:identity, :ln, :log2, :log10] const _unicodeplots_scale = [:identity, :ln, :log2, :log10]
# Additional constants # Additional constants

View File

@ -115,11 +115,14 @@ function addUnicodeSeries!(
return UnicodePlots.spy(series[:z].surf; kw...) return UnicodePlots.spy(series[:z].surf; kw...)
end end
series_kw = (;)
# now use the ! functions to add to the plot # now use the ! functions to add to the plot
if st in (:path, :straightline, :shape) if st in (:path, :straightline, :shape)
func = UnicodePlots.lineplot! func = UnicodePlots.lineplot!
elseif st == :scatter || series[:markershape] != :none elseif st == :scatter || series[:markershape] != :none
func = UnicodePlots.scatterplot! func = UnicodePlots.scatterplot!
series_kw = (; marker=series[:markershape])
else else
error("Series type $st not supported by UnicodePlots") error("Series type $st not supported by UnicodePlots")
end end
@ -129,7 +132,7 @@ function addUnicodeSeries!(
for (n, segment) in enumerate(series_segments(series, st; check = true)) for (n, segment) in enumerate(series_segments(series, st; check = true))
i, rng = segment.attr_index, segment.range i, rng = segment.attr_index, segment.range
lc = get_linecolor(series, i) lc = get_linecolor(series, i)
up = func(up, x[rng], y[rng]; color = up_color(lc), name = n == 1 ? label : "") up = func(up, x[rng], y[rng]; color = up_color(lc), name = n == 1 ? label : "", series_kw...)
end end
for (xi, yi, str, fnt) in EachAnn(series[:series_annotations], x, y) for (xi, yi, str, fnt) in EachAnn(series[:series_annotations], x, y)

View File

@ -1255,7 +1255,6 @@ _backend_skips = Dict(
:unicodeplots => [ :unicodeplots => [
5, # limits issue 5, # limits issue
6, # embedded images unsupported 6, # embedded images unsupported
13, # markers unsupported
16, # nested layout unsupported 16, # nested layout unsupported
21, # custom markers unsupported 21, # custom markers unsupported
22, # contours unsupported 22, # contours unsupported
@ -1269,7 +1268,6 @@ _backend_skips = Dict(
43, # heatmap with DateTime 43, # heatmap with DateTime
45, # error bars 45, # error bars
47, # mesh3D unsupported 47, # mesh3D unsupported
48, # markershapes unsupported
49, # polar heatmap 49, # polar heatmap
50, # 3D surface unsupported 50, # 3D surface unsupported
51, # embedded images unsupported 51, # embedded images unsupported