Merge pull request #3167 from jmert/offsetarrays_sticks
Support plotting `OffsetArray`s for `:sticks` series type
This commit is contained in:
commit
b5c8474e3f
@ -268,15 +268,15 @@ end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
newx, newy = zeros(3n), zeros(3n)
|
newx, newy = zeros(3n), zeros(3n)
|
||||||
newz = z!== nothing ? zeros(3n) : nothing
|
newz = z !== nothing ? zeros(3n) : nothing
|
||||||
for i = 1:n
|
for (i, (xi, yi, zi)) = enumerate(zip(x, y, z !== nothing ? z : 1:n))
|
||||||
rng = (3i - 2):(3i)
|
rng = (3i - 2):(3i)
|
||||||
newx[rng] = [x[i], x[i], NaN]
|
newx[rng] = [xi, xi, NaN]
|
||||||
if z !== nothing
|
if z !== nothing
|
||||||
newy[rng] = [y[i], y[i], NaN]
|
newy[rng] = [yi, yi, NaN]
|
||||||
newz[rng] = [_cycle(fr, i), z[i], NaN]
|
newz[rng] = [_cycle(fr, i), zi, NaN]
|
||||||
else
|
else
|
||||||
newy[rng] = [_cycle(fr, i), y[i], NaN]
|
newy[rng] = [_cycle(fr, i), yi, NaN]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
x := newx
|
x := newx
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
using Plots, Test
|
using Plots, Test
|
||||||
|
using OffsetArrays
|
||||||
|
|
||||||
@testset "lens!" begin
|
@testset "lens!" begin
|
||||||
pl = plot(1:5)
|
pl = plot(1:5)
|
||||||
lens!(pl, [1,2], [1,2], inset = (1, bbox(0.0,0.0,0.2,0.2)), colorbar = false)
|
lens!(pl, [1,2], [1,2], inset = (1, bbox(0.0,0.0,0.2,0.2)), colorbar = false)
|
||||||
@ -23,3 +25,9 @@ end # testset
|
|||||||
vsp = vspan([1,3], ylims=(-2,5), widen = false)
|
vsp = vspan([1,3], ylims=(-2,5), widen = false)
|
||||||
@test Plots.ylims(vsp) == (-2,5)
|
@test Plots.ylims(vsp) == (-2,5)
|
||||||
end # testset
|
end # testset
|
||||||
|
|
||||||
|
@testset "offset axes" begin
|
||||||
|
tri = OffsetVector(vcat(1:5, 4:-1:1), 11:19)
|
||||||
|
sticks = plot(tri, seriestype = :sticks)
|
||||||
|
@test length(sticks) == 1
|
||||||
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user