From 31bc74e2b1b5dc7ec2c9eaf8b78d3648f11229e8 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Thu, 21 Nov 2019 15:07:48 +0100 Subject: [PATCH] filled contours are difficult --- src/backends/pgfplotsx.jl | 20 ++++++++++++++++---- test/test_pgfplotsx.jl | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/backends/pgfplotsx.jl b/src/backends/pgfplotsx.jl index bdb7b7f9..a523cc48 100644 --- a/src/backends/pgfplotsx.jl +++ b/src/backends/pgfplotsx.jl @@ -151,7 +151,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend}) else series_func = PGFPlotsX.Plot end - if series[:fillrange] !== nothing + if series[:fillrange] !== nothing && st != :contour series_opt = merge(series_opt, pgfx_fillstyle(opt)) push!(series_opt, "area legend" => nothing) end @@ -160,13 +160,25 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend}) push!(series_opt, _pgfx_series_extrastyle[st] => nothing) end if st == :contour + if !isfilledcontour(series) surface_opt = PGFPlotsX.Options( - "contour prepared" => nothing - ) + "contour prepared" => PGFPlotsX.Options( + "labels" => opt[:contour_labels], + ) + ) + else + error("PGFPlotsX backend does not support filled contours at the moment.") + surface_opt = PGFPlotsX.Options( + "contour filled" => PGFPlotsX.Options( + # "levels" => opt[:levels], + # "labels" => opt[:contour_labels], + ) + ) + end surface_plot = series_func( # merge(series_opt, surface_opt), surface_opt, - PGFPlotsX.Table(Contour.contours(args...)) + PGFPlotsX.Table(Contour.contours(args..., opt[:levels])) ) push!(axis, surface_plot) else diff --git a/test/test_pgfplotsx.jl b/test/test_pgfplotsx.jl index de775c32..e0a2eacd 100644 --- a/test/test_pgfplotsx.jl +++ b/test/test_pgfplotsx.jl @@ -88,6 +88,6 @@ end p2 = contour(x, y, Z) p1 = contour(x, y, f, fill=true) plot(p1, p2) - # TODO: totally broken, also errors for pgfplots + # TODO: filled contours end # testset end # testset