From 6ff4dce62a3a272ec2c0ac997b1bd279f8fd0905 Mon Sep 17 00:00:00 2001 From: "Michael K. Borregaard" Date: Mon, 18 Dec 2017 08:47:15 +0100 Subject: [PATCH] Don't add `abline!` if outside plot window --- src/recipes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/recipes.jl b/src/recipes.jl index 5eab486f..07ac0c1b 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -989,7 +989,7 @@ end function abline!(plt::Plot, a, b; kw...) xl, yl = xlims(plt), ylims(plt) x1, x2 = max(xl[1], (yl[1] - b)/a), min(xl[2], (yl[2] - b)/a) - plot!(plt, x -> b + a*x, x1, x2; kw...) + x2 > x1 && plot!(plt, x -> b + a*x, x1, x2; kw...) end abline!(args...; kw...) = abline!(current(), args...; kw...)