From 4066950ecc61957a0b43438a1e46925b0f9d3935 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Fri, 13 Nov 2020 11:00:55 +0100 Subject: [PATCH] add 3dquiver to pgfplotsx --- src/backends/pgfplotsx.jl | 26 +++++++++++++++++++------- src/pipeline.jl | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/backends/pgfplotsx.jl b/src/backends/pgfplotsx.jl index 6ea2de72..20736897 100644 --- a/src/backends/pgfplotsx.jl +++ b/src/backends/pgfplotsx.jl @@ -282,7 +282,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend}) ) extra_series, extra_series_opt = pgfx_split_extra_opts(series[:extra_kwargs]) series_opt = merge(series_opt, PGFPlotsX.Options(extra_series_opt...)) - if RecipesPipeline.is3d(series) || st in (:heatmap, :contour) + if RecipesPipeline.is3d(series) || st in (:heatmap, :contour) || (st == :quiver && opt[:z] !== nothing) series_func = PGFPlotsX.Plot3 else series_func = PGFPlotsX.Plot @@ -587,12 +587,24 @@ function pgfx_add_series!(::Val{:quiver}, axis, series_opt, series, series_func, ) x = opt[:x] y = opt[:y] - table = PGFPlotsX.Table([ - :x => x, - :y => y, - :u => opt[:quiver][1], - :v => opt[:quiver][2], - ]) + if is3d(series) + push!(series_opt["quiver"], "w" => "\\thisrow{w}") + table = PGFPlotsX.Table([ + :x => x, + :y => y, + :z => opt[:z], + :u => opt[:quiver][1], + :v => opt[:quiver][2], + :w => opt[:quiver][3], + ]) + else + table = PGFPlotsX.Table([ + :x => x, + :y => y, + :u => opt[:quiver][1], + :v => opt[:quiver][2], + ]) + end end series_plot = series_func(series_opt, table) push!(axis, series_plot) diff --git a/src/pipeline.jl b/src/pipeline.jl index 7197d2df..8f493cb2 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -316,7 +316,7 @@ end function _override_seriestype_check(plotattributes::AKW, st::Symbol) # do we want to override the series type? - if !RecipesPipeline.is3d(st) && !(st in (:contour, :contour3d)) + if !RecipesPipeline.is3d(st) && !(st in (:contour, :contour3d, :quiver)) z = plotattributes[:z] if !isa(z, Nothing) && (size(plotattributes[:x]) == size(plotattributes[:y]) == size(z))