UnicodePlots: minor fixes (#3812)

This commit is contained in:
t-bltg 2021-09-15 11:21:41 +02:00 committed by GitHub
parent 198a59b621
commit c3f45dd712
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,12 +23,8 @@ function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend})
for sp in plt.subplots for sp in plt.subplots
xaxis = sp[:xaxis] xaxis = sp[:xaxis]
yaxis = sp[:yaxis] yaxis = sp[:yaxis]
xlim = axis_limits(sp, :x) xlim = collect(axis_limits(sp, :x))
ylim = axis_limits(sp, :y) ylim = collect(axis_limits(sp, :y))
# make vectors
xlim = [xlim[1], xlim[2]]
ylim = [ylim[1], ylim[2]]
# we set x/y to have a single point, since we need to create the plot with some data. # we set x/y to have a single point, since we need to create the plot with some data.
# since this point is at the bottom left corner of the plot, it shouldn't actually be shown # since this point is at the bottom left corner of the plot, it shouldn't actually be shown
@ -55,7 +51,7 @@ function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend})
o = UnicodePlots.Plot(x, y, canvas_map[canvas_type]; kw...) o = UnicodePlots.Plot(x, y, canvas_map[canvas_type]; kw...)
for series in series_list(sp) for series in series_list(sp)
o = addUnicodeSeries!(sp, o, kw, series, sp[:legend] != :none, xlim, ylim) o = addUnicodeSeries!(sp, o, kw, series, sp[:legend] != :none)
end end
for ann in sp[:annotations] for ann in sp[:annotations]
@ -86,11 +82,7 @@ end
function addUnicodeSeries!( function addUnicodeSeries!(
sp::Subplot{UnicodePlotsBackend}, sp::Subplot{UnicodePlotsBackend},
up::UnicodePlots.Plot, up::UnicodePlots.Plot,
kw, kw, series, addlegend::Bool,
series,
addlegend::Bool,
xlim,
ylim,
) )
st = series[:seriestype] st = series[:seriestype]
@ -105,6 +97,7 @@ function addUnicodeSeries!(
# special handling (src/interface) # special handling (src/interface)
if st == :histogram2d if st == :histogram2d
kw[:xlim][:] .= kw[:ylim][:] .= 0
return UnicodePlots.densityplot(x, y; kw...) return UnicodePlots.densityplot(x, y; kw...)
elseif st == :heatmap elseif st == :heatmap
rng = range(0, 1, length = length(UnicodePlots.COLOR_MAP_DATA[:viridis])) rng = range(0, 1, length = length(UnicodePlots.COLOR_MAP_DATA[:viridis]))