better line (#4085)

This commit is contained in:
Simon Christ 2022-02-18 21:13:16 +01:00 committed by GitHub
parent 51358717ee
commit 204b2178d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1037,6 +1037,8 @@ export lens!
throw(ArgumentError("Inset bounding box needs to in relative coordinates.")) throw(ArgumentError("Inset bounding box needs to in relative coordinates."))
end end
sp = plt.subplots[sp_index] sp = plt.subplots[sp_index]
xscale = sp[:xaxis][:scale]
yscale = sp[:yaxis][:scale]
xl1, xl2 = xlims(sp) xl1, xl2 = xlims(sp)
bbx1 = xl1 + left(inset_bbox).value * (xl2 - xl1) bbx1 = xl1 + left(inset_bbox).value * (xl2 - xl1)
bbx2 = bbx1 + width(inset_bbox).value * (xl2 - xl1) bbx2 = bbx1 + width(inset_bbox).value * (xl2 - xl1)
@ -1046,8 +1048,8 @@ export lens!
bbx = bbx1 + width(inset_bbox).value * (xl2 - xl1) / 2 * (sp[:xaxis][:flip] ? -1 : 1) bbx = bbx1 + width(inset_bbox).value * (xl2 - xl1) / 2 * (sp[:xaxis][:flip] ? -1 : 1)
bby = bby1 + height(inset_bbox).value * (yl2 - yl1) / 2 * (sp[:yaxis][:flip] ? -1 : 1) bby = bby1 + height(inset_bbox).value * (yl2 - yl1) / 2 * (sp[:yaxis][:flip] ? -1 : 1)
lens_index = last(plt.subplots)[:subplot_index] + 1 lens_index = last(plt.subplots)[:subplot_index] + 1
x1, x2 = plotattributes[:x] x1, x2 = RecipesPipeline.inverse_scale_func(xscale).(plotattributes[:x])
y1, y2 = plotattributes[:y] y1, y2 = RecipesPipeline.inverse_scale_func(yscale).(plotattributes[:y])
backup = copy(plotattributes) backup = copy(plotattributes)
empty!(plotattributes) empty!(plotattributes)
@ -1072,8 +1074,8 @@ export lens!
@series begin @series begin
primary := false primary := false
subplot := sp_index subplot := sp_index
x := [xi_mag, xi_lens] x := RecipesPipeline.scale_func(xscale).([xi_mag, xi_lens])
y := [yi_mag, yi_lens] y := RecipesPipeline.scale_func(yscale).([yi_mag, yi_lens])
() ()
end end
end end
@ -1081,8 +1083,8 @@ export lens!
@series begin @series begin
primary := false primary := false
subplot := sp_index subplot := sp_index
x := [x1, x1, x2, x2, x1] x := RecipesPipeline.scale_func(xscale).([x1, x1, x2, x2, x1])
y := [y1, y2, y2, y1, y1] y := RecipesPipeline.scale_func(yscale).([y1, y2, y2, y1, y1])
() ()
end end
# add subplot # add subplot
@ -1091,8 +1093,8 @@ export lens!
plotattributes = merge(backup, copy(series.plotattributes)) plotattributes = merge(backup, copy(series.plotattributes))
subplot := lens_index subplot := lens_index
primary := false primary := false
xlims := (x1, x2) xlims := RecipesPipeline.scale_func(xscale).((x1, x2))
ylims := (y1, y2) ylims := RecipesPipeline.scale_func(yscale).((y1, y2))
() ()
end end
end end