Merge remote-tracking branch 'upstream/master' into ttl_frame
This commit is contained in:
commit
d4622c51ae
@ -55,7 +55,7 @@ Scratch = "1"
|
|||||||
Showoff = "0.3.1, 1.0"
|
Showoff = "0.3.1, 1.0"
|
||||||
StatsBase = "0.32 - 0.33"
|
StatsBase = "0.32 - 0.33"
|
||||||
UnicodeFun = "0.4"
|
UnicodeFun = "0.4"
|
||||||
UnicodePlots = "2.6"
|
UnicodePlots = "2.8"
|
||||||
Unzip = "0.1"
|
Unzip = "0.1"
|
||||||
julia = "1.6"
|
julia = "1.6"
|
||||||
|
|
||||||
|
|||||||
@ -914,7 +914,7 @@ const _unicodeplots_attr = merge_with_base_supported([
|
|||||||
:annotations,
|
:annotations,
|
||||||
:bins,
|
:bins,
|
||||||
:guide,
|
:guide,
|
||||||
# :grid,
|
:grid,
|
||||||
:label,
|
:label,
|
||||||
:layout,
|
:layout,
|
||||||
:legend,
|
:legend,
|
||||||
@ -928,18 +928,27 @@ const _unicodeplots_attr = merge_with_base_supported([
|
|||||||
:seriesalpha,
|
:seriesalpha,
|
||||||
:seriescolor,
|
:seriescolor,
|
||||||
:scale,
|
:scale,
|
||||||
|
:flip,
|
||||||
:title,
|
:title,
|
||||||
|
# :marker_z,
|
||||||
|
:line_z,
|
||||||
])
|
])
|
||||||
const _unicodeplots_seriestype = [
|
const _unicodeplots_seriestype = [
|
||||||
:path,
|
:path,
|
||||||
|
:path3d,
|
||||||
:scatter,
|
:scatter,
|
||||||
|
:scatter3d,
|
||||||
:straightline,
|
:straightline,
|
||||||
# :bar,
|
# :bar,
|
||||||
:shape,
|
:shape,
|
||||||
:histogram2d,
|
:histogram2d,
|
||||||
:heatmap,
|
:heatmap,
|
||||||
:contour,
|
:contour,
|
||||||
|
# :contour3d,
|
||||||
:spy,
|
:spy,
|
||||||
|
:surface,
|
||||||
|
:wireframe,
|
||||||
|
:mesh3d,
|
||||||
]
|
]
|
||||||
const _unicodeplots_style = [:auto, :solid]
|
const _unicodeplots_style = [:auto, :solid]
|
||||||
const _unicodeplots_marker = [
|
const _unicodeplots_marker = [
|
||||||
@ -972,9 +981,6 @@ const _unicodeplots_marker = [
|
|||||||
]
|
]
|
||||||
const _unicodeplots_scale = [:identity, :ln, :log2, :log10]
|
const _unicodeplots_scale = [:identity, :ln, :log2, :log10]
|
||||||
|
|
||||||
# Additional constants
|
|
||||||
const _up_colormap = Ref(:none)
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# hdf5
|
# hdf5
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,6 @@ const _canvas_map = (
|
|||||||
# do all the magic here... build it all at once,
|
# do all the magic here... build it all at once,
|
||||||
# since we need to know about all the series at the very beginning
|
# since we need to know about all the series at the very beginning
|
||||||
function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend})
|
function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend})
|
||||||
plt.attr[:warn_on_unsupported] = false
|
|
||||||
plt.o = UnicodePlots.Plot[]
|
plt.o = UnicodePlots.Plot[]
|
||||||
|
|
||||||
has_layout = prod(size(plt.layout)) > 1
|
has_layout = prod(size(plt.layout)) > 1
|
||||||
@ -25,24 +24,26 @@ function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend})
|
|||||||
yaxis = sp[:yaxis]
|
yaxis = sp[:yaxis]
|
||||||
xlim = collect(axis_limits(sp, :x))
|
xlim = collect(axis_limits(sp, :x))
|
||||||
ylim = collect(axis_limits(sp, :y))
|
ylim = collect(axis_limits(sp, :y))
|
||||||
|
zlim = collect(axis_limits(sp, :z))
|
||||||
F = float(eltype(xlim))
|
F = float(eltype(xlim))
|
||||||
|
|
||||||
# We set x/y to have a single point,
|
# We set x/y to have a single point,
|
||||||
# since we need to create the plot with some data.
|
# since we need to create the plot with some data.
|
||||||
# Since this point is at the bottom left corner of the plot,
|
# Since this point is at the bottom left corner of the plot,
|
||||||
# it should be hidden by consecutive plotting commands.
|
# it should be hidden by consecutive plotting commands.
|
||||||
x = F[xlim[1]]
|
x = Vector{F}(xlim)
|
||||||
y = F[ylim[1]]
|
y = Vector{F}(ylim)
|
||||||
|
z = Vector{F}(zlim)
|
||||||
|
|
||||||
# create a plot window with xlim/ylim set,
|
# create a plot window with xlim/ylim set,
|
||||||
# but the X/Y vectors are outside the bounds
|
# but the X/Y vectors are outside the bounds
|
||||||
canvas = if (up_c = get(sp[:extra_kwargs], :canvas, :auto)) == :auto
|
canvas = if (up_c = get(sp[:extra_kwargs], :canvas, :auto)) === :auto
|
||||||
isijulia() ? :ascii : :braille
|
isijulia() ? :ascii : :braille
|
||||||
else
|
else
|
||||||
up_c
|
up_c
|
||||||
end
|
end
|
||||||
|
|
||||||
border = if (up_b = get(sp[:extra_kwargs], :border, :auto)) == :auto
|
border = if (up_b = get(sp[:extra_kwargs], :border, :auto)) === :auto
|
||||||
isijulia() ? :ascii : :solid
|
isijulia() ? :ascii : :solid
|
||||||
else
|
else
|
||||||
up_b
|
up_b
|
||||||
@ -52,6 +53,7 @@ function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend})
|
|||||||
width = has_layout && isempty(series_list(sp)) ? 0 : UnicodePlots.DEFAULT_WIDTH[]
|
width = has_layout && isempty(series_list(sp)) ? 0 : UnicodePlots.DEFAULT_WIDTH[]
|
||||||
height = UnicodePlots.DEFAULT_HEIGHT[]
|
height = UnicodePlots.DEFAULT_HEIGHT[]
|
||||||
|
|
||||||
|
plot_3d = is3d(sp)
|
||||||
blend = get(sp[:extra_kwargs], :blend, true)
|
blend = get(sp[:extra_kwargs], :blend, true)
|
||||||
grid = xaxis[:grid] && yaxis[:grid]
|
grid = xaxis[:grid] && yaxis[:grid]
|
||||||
quiver = contour = false
|
quiver = contour = false
|
||||||
@ -70,6 +72,8 @@ function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend})
|
|||||||
grid &= !(quiver || contour)
|
grid &= !(quiver || contour)
|
||||||
blend &= !(quiver || contour)
|
blend &= !(quiver || contour)
|
||||||
|
|
||||||
|
plot_3d && (xlim = ylim = (0, 0)) # determined using projection
|
||||||
|
|
||||||
kw = (
|
kw = (
|
||||||
compact = true,
|
compact = true,
|
||||||
title = texmath2unicode(sp[:title]),
|
title = texmath2unicode(sp[:title]),
|
||||||
@ -84,11 +88,24 @@ function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend})
|
|||||||
border = border,
|
border = border,
|
||||||
xlim = xlim,
|
xlim = xlim,
|
||||||
ylim = ylim,
|
ylim = ylim,
|
||||||
|
# 3d
|
||||||
|
projection = plot_3d ? :orthographic : nothing,
|
||||||
|
up = sp[:zaxis][:flip] ? :mz : :pz,
|
||||||
|
# PyPlot: azimuth = -60 & elevation = 30
|
||||||
|
azimuth = -45,
|
||||||
|
elevation = 30,
|
||||||
)
|
)
|
||||||
|
|
||||||
o = UnicodePlots.Plot(x, y, _canvas_map[canvas]; kw...)
|
o = UnicodePlots.Plot(x, y, plot_3d ? z : nothing, _canvas_map[canvas]; kw...)
|
||||||
for series in series_list(sp)
|
for series in series_list(sp)
|
||||||
o = addUnicodeSeries!(sp, o, kw, series, sp[:legend_position] != :none)
|
o = addUnicodeSeries!(
|
||||||
|
sp,
|
||||||
|
o,
|
||||||
|
kw,
|
||||||
|
series,
|
||||||
|
sp[:legend_position] !== :none,
|
||||||
|
plot_3d,
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
for ann in sp[:annotations]
|
for ann in sp[:annotations]
|
||||||
@ -125,6 +142,7 @@ function addUnicodeSeries!(
|
|||||||
kw,
|
kw,
|
||||||
series,
|
series,
|
||||||
addlegend::Bool,
|
addlegend::Bool,
|
||||||
|
plot_3d::Bool,
|
||||||
)
|
)
|
||||||
st = series[:seriestype]
|
st = series[:seriestype]
|
||||||
|
|
||||||
@ -134,7 +152,7 @@ function addUnicodeSeries!(
|
|||||||
elseif st === :shape
|
elseif st === :shape
|
||||||
shape_data(series)
|
shape_data(series)
|
||||||
else
|
else
|
||||||
float(series[:x]), float(series[:y])
|
series[:x], series[:y]
|
||||||
end
|
end
|
||||||
|
|
||||||
# special handling (src/interface)
|
# special handling (src/interface)
|
||||||
@ -142,12 +160,13 @@ function addUnicodeSeries!(
|
|||||||
if st === :histogram2d
|
if st === :histogram2d
|
||||||
return UnicodePlots.densityplot(x, y; kw...)
|
return UnicodePlots.densityplot(x, y; kw...)
|
||||||
elseif st === :spy
|
elseif st === :spy
|
||||||
return UnicodePlots.spy(series[:z].surf; fix_ar = fix_ar, kw...)
|
return UnicodePlots.spy(Array(series[:z]); fix_ar = fix_ar, kw...)
|
||||||
elseif st in (:contour, :heatmap)
|
elseif st in (:contour, :heatmap) # 2D
|
||||||
|
colormap = get(series[:extra_kwargs], :colormap, :none)
|
||||||
kw = (
|
kw = (
|
||||||
kw...,
|
kw...,
|
||||||
zlabel = sp[:colorbar_title],
|
zlabel = sp[:colorbar_title],
|
||||||
colormap = (cm = _up_colormap[] === :none) ? up_cmap(series) : cm,
|
colormap = colormap === :none ? up_cmap(series) : colormap,
|
||||||
colorbar = hascolorbar(sp),
|
colorbar = hascolorbar(sp),
|
||||||
)
|
)
|
||||||
if st === :contour
|
if st === :contour
|
||||||
@ -156,21 +175,36 @@ function addUnicodeSeries!(
|
|||||||
return UnicodePlots.contourplot(
|
return UnicodePlots.contourplot(
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
series[:z].surf;
|
Array(series[:z]);
|
||||||
kw...,
|
kw...,
|
||||||
levels = series[:levels],
|
levels = series[:levels],
|
||||||
)
|
)
|
||||||
elseif st === :heatmap
|
elseif st === :heatmap
|
||||||
return UnicodePlots.heatmap(series[:z].surf; fix_ar = fix_ar, kw...)
|
return UnicodePlots.heatmap(Array(series[:z]); fix_ar = fix_ar, kw...)
|
||||||
# zlim = collect(axis_limits(sp, :z))
|
|
||||||
end
|
end
|
||||||
|
elseif st in (:surface, :wireframe) # 3D
|
||||||
|
colormap = get(series[:extra_kwargs], :colormap, :none)
|
||||||
|
kw = (
|
||||||
|
kw...,
|
||||||
|
zlabel = sp[:colorbar_title],
|
||||||
|
colormap = colormap === :none ? up_cmap(series) : colormap,
|
||||||
|
colorbar = hascolorbar(sp),
|
||||||
|
color = st === :wireframe ? up_color(get_linecolor(series, 1)) : nothing,
|
||||||
|
lines = st === :wireframe,
|
||||||
|
)
|
||||||
|
return UnicodePlots.surfaceplot(x, y, Array(series[:z]); kw...)
|
||||||
|
elseif st === :mesh3d
|
||||||
|
return UnicodePlots.lineplot!(
|
||||||
|
up,
|
||||||
|
mesh3d_triangles(x, y, series[:z], series[:connections])...,
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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, :path3d, :straightline, :shape, :mesh3d)
|
||||||
func = UnicodePlots.lineplot!
|
func = UnicodePlots.lineplot!
|
||||||
series_kw = (; head_tail = series[:arrow] isa Arrow ? series[:arrow].side : nothing)
|
series_kw = (; head_tail = series[:arrow] isa Arrow ? series[:arrow].side : nothing)
|
||||||
elseif st === :scatter || series[:markershape] != :none
|
elseif st in (:scatter, :scatter3d) || series[:markershape] !== :none
|
||||||
func = UnicodePlots.scatterplot!
|
func = UnicodePlots.scatterplot!
|
||||||
series_kw = (; marker = series[:markershape])
|
series_kw = (; marker = series[:markershape])
|
||||||
else
|
else
|
||||||
@ -185,7 +219,8 @@ function addUnicodeSeries!(
|
|||||||
up = func(
|
up = func(
|
||||||
up,
|
up,
|
||||||
x[rng],
|
x[rng],
|
||||||
y[rng];
|
y[rng],
|
||||||
|
plot_3d ? series[:z][rng] : nothing;
|
||||||
color = up_color(lc),
|
color = up_color(lc),
|
||||||
name = n == 1 ? label : "",
|
name = n == 1 ? label : "",
|
||||||
series_kw...,
|
series_kw...,
|
||||||
|
|||||||
@ -1302,7 +1302,6 @@ _backend_skips = Dict(
|
|||||||
6, # embedded images unsupported
|
6, # embedded images unsupported
|
||||||
16, # nested layout unsupported
|
16, # nested layout unsupported
|
||||||
21, # custom markers unsupported
|
21, # custom markers unsupported
|
||||||
24, # 3D unsupported
|
|
||||||
26, # nested layout unsupported
|
26, # nested layout unsupported
|
||||||
27, # polar plots unsupported
|
27, # polar plots unsupported
|
||||||
29, # nested layout unsupported
|
29, # nested layout unsupported
|
||||||
@ -1311,12 +1310,9 @@ _backend_skips = Dict(
|
|||||||
37, # ribbons / filled unsupported
|
37, # ribbons / filled unsupported
|
||||||
43, # heatmap with DateTime
|
43, # heatmap with DateTime
|
||||||
45, # error bars
|
45, # error bars
|
||||||
47, # mesh3D unsupported
|
|
||||||
49, # polar heatmap
|
49, # polar heatmap
|
||||||
50, # 3D surface unsupported
|
|
||||||
51, # embedded images unsupported
|
51, # embedded images unsupported
|
||||||
52, # 3D quiver unsupported
|
55, # mirror unsupported, resolution too low
|
||||||
55, # 3D unsupported
|
|
||||||
56, # barplots
|
56, # barplots
|
||||||
],
|
],
|
||||||
:gaston => [
|
:gaston => [
|
||||||
@ -1342,11 +1338,8 @@ function test_examples(pkgname::Symbol, idx::Int; debug = false, disp = true)
|
|||||||
Base.eval(m, :(using Plots))
|
Base.eval(m, :(using Plots))
|
||||||
map(exprs -> Base.eval(m, exprs), _examples[idx].exprs)
|
map(exprs -> Base.eval(m, exprs), _examples[idx].exprs)
|
||||||
|
|
||||||
plt = current()
|
disp && Base.eval(m, :(gui(current())))
|
||||||
if disp
|
current()
|
||||||
gui(plt)
|
|
||||||
end
|
|
||||||
plt
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# generate all plots and create a dict mapping idx --> plt
|
# generate all plots and create a dict mapping idx --> plt
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user