toggle contour example

This commit is contained in:
t-bltg 2022-01-13 11:52:05 +01:00
parent 143c77334b
commit 2c35964879
2 changed files with 7 additions and 5 deletions

View File

@ -117,6 +117,7 @@ function addUnicodeSeries!(
kw[:xlim][:] .= kw[:ylim][:] .= 0 kw[:xlim][:] .= kw[:ylim][:] .= 0
return UnicodePlots.densityplot(x, y; kw...) return UnicodePlots.densityplot(x, y; kw...)
elseif st === :spy elseif st === :spy
kw = (; kw..., width = 0, height = 0) # w/h handled in UnicodePlots
return UnicodePlots.spy(series[:z].surf; kw...) return UnicodePlots.spy(series[:z].surf; kw...)
elseif st in (:contour, :heatmap) elseif st in (:contour, :heatmap)
kw_hm_ct = (; kw_hm_ct = (;
@ -125,11 +126,13 @@ function addUnicodeSeries!(
colorbar = hascolorbar(sp), colorbar = hascolorbar(sp),
) )
if st === :contour if st === :contour
isfilledcontour(series) && @warn "Plots(UnicodePlots): filled contour is not implemented"
return UnicodePlots.contourplot( return UnicodePlots.contourplot(
x, y, series[:z].surf; x, y, series[:z].surf;
levels = series[:levels], kw_hm_ct..., kw... levels = series[:levels], kw_hm_ct..., kw...
) )
else else
kw = (; kw..., width = 0, height = 0) # w/h handled in UnicodePlots
return UnicodePlots.heatmap(series[:z].surf; kw_hm_ct..., kw...) return UnicodePlots.heatmap(series[:z].surf; kw_hm_ct..., kw...)
end end
end end
@ -142,7 +145,7 @@ function addUnicodeSeries!(
func = UnicodePlots.scatterplot! func = UnicodePlots.scatterplot!
series_kw = (; marker = series[:markershape]) series_kw = (; marker = series[:markershape])
else else
error("Series type $st not supported by UnicodePlots") error("Plots(UnicodePlots): series type $st not supported")
end end
label = addlegend ? series[:label] : "" label = addlegend ? series[:label] : ""
@ -172,7 +175,7 @@ function addUnicodeSeries!(
) )
end end
return up up
end end
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------
@ -208,7 +211,7 @@ end
Base.show(plt::Plot{UnicodePlotsBackend}) = show(stdout, plt) Base.show(plt::Plot{UnicodePlotsBackend}) = show(stdout, plt)
Base.show(io::IO, plt::Plot{UnicodePlotsBackend}) = _show(io, MIME("text/plain"), plt) Base.show(io::IO, plt::Plot{UnicodePlotsBackend}) = _show(io, MIME("text/plain"), plt)
# NOTE: _show(..) must be kept for Base.showable (src/output.jl) # NOTE: _show(...) must be kept for Base.showable (src/output.jl)
function _show(io::IO, ::MIME"text/plain", plt::Plot{UnicodePlotsBackend}) function _show(io::IO, ::MIME"text/plain", plt::Plot{UnicodePlotsBackend})
unicodeplots_rebuild(plt) unicodeplots_rebuild(plt)
nr, nc = size(plt.layout) nr, nc = size(plt.layout)
@ -232,7 +235,7 @@ function _show(io::IO, ::MIME"text/plain", plt::Plot{UnicodePlotsBackend})
for c in 1:nc for c in 1:nc
l = plt.layout[r, c] l = plt.layout[r, c]
if l isa GridLayout && size(l) != (1, 1) if l isa GridLayout && size(l) != (1, 1)
@error "UnicodePlots: complex nested layout is currently unsupported !" @error "Plots(UnicodePlots): complex nested layout is currently unsupported"
else else
if get(l.attr, :blank, false) if get(l.attr, :blank, false)
lines_colored[r, c] = lines_uncolored[r, c] = nothing lines_colored[r, c] = lines_uncolored[r, c] = nothing

View File

@ -1289,7 +1289,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
22, # contours unsupported
24, # 3D unsupported 24, # 3D unsupported
26, # nested layout unsupported 26, # nested layout unsupported
27, # polar plots unsupported 27, # polar plots unsupported