fix extra series in lens! (#2919)
* fix extra series in lens! * include tests
This commit is contained in:
parent
960e7dbcd9
commit
1b70fb18e4
@ -919,7 +919,7 @@ end
|
|||||||
@recipe function f(::Type{Val{:mesh3d}}, x, y, z)
|
@recipe function f(::Type{Val{:mesh3d}}, x, y, z)
|
||||||
# As long as no i,j,k are supplied this should work with PyPlot and GR
|
# As long as no i,j,k are supplied this should work with PyPlot and GR
|
||||||
seriestype := :surface
|
seriestype := :surface
|
||||||
if plotattributes[:connections] != nothing
|
if plotattributes[:connections] != nothing
|
||||||
throw(ArgumentError("Giving triangles using the connections argument is only supported on Plotly backend."))
|
throw(ArgumentError("Giving triangles using the connections argument is only supported on Plotly backend."))
|
||||||
end
|
end
|
||||||
()
|
()
|
||||||
@ -962,8 +962,12 @@ export lens!
|
|||||||
lens_index = last(plt.subplots)[:subplot_index] + 1
|
lens_index = last(plt.subplots)[:subplot_index] + 1
|
||||||
x1, x2 = plotattributes[:x]
|
x1, x2 = plotattributes[:x]
|
||||||
y1, y2 = plotattributes[:y]
|
y1, y2 = plotattributes[:y]
|
||||||
|
backup = copy(plotattributes)
|
||||||
|
empty!(plotattributes)
|
||||||
|
|
||||||
|
series_plotindex := backup[:series_plotindex]
|
||||||
seriestype := :path
|
seriestype := :path
|
||||||
label := ""
|
primary := false
|
||||||
linecolor := :lightgray
|
linecolor := :lightgray
|
||||||
bbx_mag = (x1 + x2) / 2
|
bbx_mag = (x1 + x2) / 2
|
||||||
bby_mag = (y1 + y2) / 2
|
bby_mag = (y1 + y2) / 2
|
||||||
@ -973,6 +977,7 @@ export lens!
|
|||||||
if xl1 < xi_lens < xl2 &&
|
if xl1 < xi_lens < xl2 &&
|
||||||
yl1 < yi_lens < yl2
|
yl1 < yi_lens < yl2
|
||||||
@series begin
|
@series begin
|
||||||
|
primary := false
|
||||||
subplot := sp_index
|
subplot := sp_index
|
||||||
x := [xi_mag, xi_lens]
|
x := [xi_mag, xi_lens]
|
||||||
y := [yi_mag, yi_lens]
|
y := [yi_mag, yi_lens]
|
||||||
@ -981,6 +986,7 @@ export lens!
|
|||||||
end
|
end
|
||||||
# add magnification shape
|
# add magnification shape
|
||||||
@series begin
|
@series begin
|
||||||
|
primary := false
|
||||||
subplot := sp_index
|
subplot := sp_index
|
||||||
x := [x1, x1, x2, x2, x1]
|
x := [x1, x1, x2, x2, x1]
|
||||||
y := [y1, y2, y2, y1, y1]
|
y := [y1, y2, y2, y1, y1]
|
||||||
@ -991,16 +997,13 @@ export lens!
|
|||||||
@series begin
|
@series begin
|
||||||
plotattributes = merge(plotattributes, copy(series.plotattributes))
|
plotattributes = merge(plotattributes, copy(series.plotattributes))
|
||||||
subplot := lens_index
|
subplot := lens_index
|
||||||
label := ""
|
primary := false
|
||||||
xlims := (x1, x2)
|
xlims := (x1, x2)
|
||||||
ylims := (y1, y2)
|
ylims := (y1, y2)
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
backup = copy(plotattributes)
|
nothing
|
||||||
empty!(plotattributes)
|
|
||||||
seriestype := :path
|
|
||||||
series_plotindex := backup[:series_plotindex]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function intersection_point(xA, yA, xB, yB, h, w)
|
function intersection_point(xA, yA, xB, yB, h, w)
|
||||||
@ -1546,4 +1549,3 @@ julia> areaplot(1:3, [1 2 3; 7 8 9; 4 5 6], seriescolor = [:red :green :blue], f
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import GeometryTypes, GeometryBasics
|
|||||||
using Dates
|
using Dates
|
||||||
|
|
||||||
include("test_axes.jl")
|
include("test_axes.jl")
|
||||||
|
include("test_recipes.jl")
|
||||||
include("test_hdf5plots.jl")
|
include("test_hdf5plots.jl")
|
||||||
include("test_pgfplotsx.jl")
|
include("test_pgfplotsx.jl")
|
||||||
|
|
||||||
|
|||||||
6
test/test_recipes.jl
Normal file
6
test/test_recipes.jl
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
using Plots, Test
|
||||||
|
@testset "lens!" begin
|
||||||
|
pl = plot(1:5)
|
||||||
|
lens!(pl, [1,2], [1,2], inset = (1, bbox(0.0,0.0,0.2,0.2)))
|
||||||
|
@test length(pl.series_list) == 4
|
||||||
|
end # testset
|
||||||
Loading…
x
Reference in New Issue
Block a user