add 3dquiver to pgfplotsx

This commit is contained in:
Simon Christ 2020-11-13 11:00:55 +01:00
parent 5861b1f11f
commit 4066950ecc
2 changed files with 20 additions and 8 deletions

View File

@ -282,7 +282,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
) )
extra_series, extra_series_opt = pgfx_split_extra_opts(series[:extra_kwargs]) extra_series, extra_series_opt = pgfx_split_extra_opts(series[:extra_kwargs])
series_opt = merge(series_opt, PGFPlotsX.Options(extra_series_opt...)) 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 series_func = PGFPlotsX.Plot3
else else
series_func = PGFPlotsX.Plot series_func = PGFPlotsX.Plot
@ -587,12 +587,24 @@ function pgfx_add_series!(::Val{:quiver}, axis, series_opt, series, series_func,
) )
x = opt[:x] x = opt[:x]
y = opt[:y] y = opt[:y]
table = PGFPlotsX.Table([ if is3d(series)
:x => x, push!(series_opt["quiver"], "w" => "\\thisrow{w}")
:y => y, table = PGFPlotsX.Table([
:u => opt[:quiver][1], :x => x,
:v => opt[:quiver][2], :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 end
series_plot = series_func(series_opt, table) series_plot = series_func(series_opt, table)
push!(axis, series_plot) push!(axis, series_plot)

View File

@ -316,7 +316,7 @@ end
function _override_seriestype_check(plotattributes::AKW, st::Symbol) function _override_seriestype_check(plotattributes::AKW, st::Symbol)
# do we want to override the series type? # 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] z = plotattributes[:z]
if !isa(z, Nothing) && if !isa(z, Nothing) &&
(size(plotattributes[:x]) == size(plotattributes[:y]) == size(z)) (size(plotattributes[:x]) == size(plotattributes[:y]) == size(z))