set projection for 3dquivers (#3544)

* set projection for 3dquivers

* fix test
This commit is contained in:
Simon Christ 2021-06-04 17:08:33 +02:00 committed by GitHub
parent 4723c513be
commit d51059f0e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -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

View File

@ -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