From a29ed28a0e82ce1d48ca64f75026dd101ca37147 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Thu, 3 Feb 2022 17:33:20 +0100 Subject: [PATCH] add `:mesh3d` --- src/backends.jl | 2 +- src/backends/unicodeplots.jl | 15 +++++++++++---- src/examples.jl | 1 - 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/backends.jl b/src/backends.jl index fa19a2ac..e426cda0 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -948,7 +948,7 @@ const _unicodeplots_seriestype = [ :spy, :surface, :wireframe, - # :mesh3d, + :mesh3d, ] const _unicodeplots_style = [:auto, :solid] const _unicodeplots_marker = [ diff --git a/src/backends/unicodeplots.jl b/src/backends/unicodeplots.jl index 5aebf343..70fef1dc 100644 --- a/src/backends/unicodeplots.jl +++ b/src/backends/unicodeplots.jl @@ -90,8 +90,10 @@ function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend}) ylim = ylim, # 3d projection = plot_3d ? :orthographic : nothing, - azimuth = -50, up = sp[:zaxis][:flip] ? :mz : :pz, + # PyPlot: azimuth = -60 & elevation = 30 + azimuth = -45, + elevation = 30, ) o = UnicodePlots.Plot(x, y, plot_3d ? z : nothing, _canvas_map[canvas]; kw...) @@ -173,20 +175,25 @@ function addUnicodeSeries!( elseif st === :heatmap return UnicodePlots.heatmap(Array(series[:z]); fix_ar = fix_ar, kw...) end - elseif st in (:wireframe, :surface) # 3D + 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 + 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 # now use the ! functions to add to the plot - if st in (:path, :path3d, :straightline, :shape) + if st in (:path, :path3d, :straightline, :shape, :mesh3d) func = UnicodePlots.lineplot! series_kw = (; head_tail = series[:arrow] isa Arrow ? series[:arrow].side : nothing) elseif st in (:scatter, :scatter3d) || series[:markershape] !== :none diff --git a/src/examples.jl b/src/examples.jl index 0d4fcb9b..2524d391 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -1310,7 +1310,6 @@ _backend_skips = Dict( 37, # ribbons / filled unsupported 43, # heatmap with DateTime 45, # error bars - 47, # mesh3D unsupported 49, # polar heatmap 51, # embedded images unsupported 55, # mirror unsupported, resolution too low