From d51059f0e93ecc8f767f07298d47a6ad7b51ba63 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Fri, 4 Jun 2021 17:08:33 +0200 Subject: [PATCH] set projection for 3dquivers (#3544) * set projection for 3dquivers * fix test --- src/pipeline.jl | 4 ++-- test/test_axes.jl | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pipeline.jl b/src/pipeline.jl index c360649b..d87c5836 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -313,7 +313,7 @@ function _prepare_subplot(plt::Plot{T}, plotattributes::AKW) where {T} st = _override_seriestype_check(plotattributes, st) # change to a 3d projection for this subplot? - if RecipesPipeline.needs_3d_axes(st) + if RecipesPipeline.needs_3d_axes(st) || (st == :quiver && plotattributes[:z] !== nothing) sp.attr[:projection] = "3d" end @@ -329,7 +329,7 @@ function _override_seriestype_check(plotattributes::AKW, st::Symbol) # do we want to override the series type? if !RecipesPipeline.is3d(st) && !(st in (:contour, :contour3d, :quiver)) z = plotattributes[:z] - if !isa(z, Nothing) && + if z !== nothing && (size(plotattributes[:x]) == size(plotattributes[:y]) == size(z)) st = (st == :scatter ? :scatter3d : :path3d) plotattributes[:seriestype] = st diff --git a/test/test_axes.jl b/test/test_axes.jl index 3f2170cb..78ca09ac 100644 --- a/test/test_axes.jl +++ b/test/test_axes.jl @@ -36,3 +36,8 @@ end pl = plot(1:5, xlims=:symmetric, widen = false) @test Plots.xlims(pl) == (-5, 5) end + +@testset "3D Axis" begin + ql = quiver([1, 2], [2, 1], [3, 4], quiver = ([1, -1], [0, 0], [1, -0.5]), arrow=true) + @test ql[1][:projection] == "3d" +end