correctly handle arrow.side = :both
This commit is contained in:
parent
7f9e6c5028
commit
a806952aa5
@ -404,26 +404,31 @@ function pgfx_add_series!(::Val{:path}, axis, series_opt, series, series_func, o
|
|||||||
PGFPlotsX.Options("quiver" => PGFPlotsX.Options(
|
PGFPlotsX.Options("quiver" => PGFPlotsX.Options(
|
||||||
"u" => "\\thisrow{u}",
|
"u" => "\\thisrow{u}",
|
||||||
"v" => "\\thisrow{v}",
|
"v" => "\\thisrow{v}",
|
||||||
pgfx_arrow(arrow) => nothing,
|
pgfx_arrow(arrow, :head) => nothing,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if arrow.side in (:head, :both)
|
if arrow.side == :head
|
||||||
x_arrow = opt[:x][rng][end-1:end]
|
x_arrow = opt[:x][rng][end-1:end]
|
||||||
y_arrow = opt[:y][rng][end-1:end]
|
y_arrow = opt[:y][rng][end-1:end]
|
||||||
x_path = opt[:x][rng][1:end-1]
|
x_path = opt[:x][rng][1:end-1]
|
||||||
y_path = opt[:y][rng][1:end-1]
|
y_path = opt[:y][rng][1:end-1]
|
||||||
elseif arrow.side in (:tail, :both)
|
elseif arrow.side == :tail
|
||||||
x_arrow = opt[:x][rng][1:2]
|
x_arrow = opt[:x][rng][2:-1:1]
|
||||||
y_arrow = opt[:y][rng][1:2]
|
y_arrow = opt[:y][rng][2:-1:1]
|
||||||
x_path = opt[:x][rng][2:end]
|
x_path = opt[:x][rng][2:end]
|
||||||
y_path = opt[:y][rng][2:end]
|
y_path = opt[:y][rng][2:end]
|
||||||
|
elseif arrow.side == :both
|
||||||
|
x_arrow = opt[:x][rng][[2,1,end-1,end]]
|
||||||
|
y_arrow = opt[:y][rng][[2,1,end-1,end]]
|
||||||
|
x_path = opt[:x][rng][2:end-1]
|
||||||
|
y_path = opt[:y][rng][2:end-1]
|
||||||
end
|
end
|
||||||
coordinates = PGFPlotsX.Table([
|
coordinates = PGFPlotsX.Table([
|
||||||
:x => x_arrow[end-1],
|
:x => x_arrow[1:2:end-1],
|
||||||
:y => y_arrow[end-1],
|
:y => y_arrow[1:2:end-1],
|
||||||
:u => diff(x_arrow),
|
:u => [x_arrow[i] - x_arrow[i-1] for i in 2:2:lastindex(x_arrow)],
|
||||||
:v => diff(y_arrow),
|
:v => [y_arrow[i] - y_arrow[i-1] for i in 2:2:lastindex(y_arrow)],
|
||||||
])
|
])
|
||||||
arrow_plot =
|
arrow_plot =
|
||||||
series_func(merge(series_opt, arrow_opt), coordinates)
|
series_func(merge(series_opt, arrow_opt), coordinates)
|
||||||
@ -754,7 +759,7 @@ end
|
|||||||
## --------------------------------------------------------------------------------------
|
## --------------------------------------------------------------------------------------
|
||||||
# Generates a colormap for pgfplots based on a ColorGradient
|
# Generates a colormap for pgfplots based on a ColorGradient
|
||||||
pgfx_arrow(::Nothing) = "every arrow/.append style={-}"
|
pgfx_arrow(::Nothing) = "every arrow/.append style={-}"
|
||||||
function pgfx_arrow(arr::Arrow)
|
function pgfx_arrow(arr::Arrow, side = arr.side)
|
||||||
components = String[]
|
components = String[]
|
||||||
head = String[]
|
head = String[]
|
||||||
push!(head, "{stealth[length = $(arr.headlength)pt, width = $(arr.headwidth)pt")
|
push!(head, "{stealth[length = $(arr.headlength)pt, width = $(arr.headwidth)pt")
|
||||||
@ -763,11 +768,11 @@ function pgfx_arrow(arr::Arrow)
|
|||||||
end
|
end
|
||||||
push!(head, "]}")
|
push!(head, "]}")
|
||||||
head = join(head, "")
|
head = join(head, "")
|
||||||
if arr.side == :both || arr.side == :tail
|
if side == :both || side == :tail
|
||||||
push!(components, head)
|
push!(components, head)
|
||||||
end
|
end
|
||||||
push!(components, "-")
|
push!(components, "-")
|
||||||
if arr.side == :both || arr.side == :head
|
if side == :both || side == :head
|
||||||
push!(components, head)
|
push!(components, head)
|
||||||
end
|
end
|
||||||
components = join(components, "")
|
components = join(components, "")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user