Skip to content

Commit f6dcbf5

Browse files
Merge pull request #112 from nmoran/layout-extrema-corner-case
Fix for corner case where spread is zero
2 parents ce94183 + 20343ab commit f6dcbf5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/plot.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ function gplot(g::AbstractGraph{T},
129129
min_x, max_x = extrema(locs_x)
130130
min_y, max_y = extrema(locs_y)
131131
function scaler(z, a, b)
132-
2.0 * ((z - a) / (b - a)) - 1.0
132+
if (a - b) == 0.0
133+
return 0.5
134+
else
135+
return 2.0 * ((z - a) / (b - a)) - 1.0
136+
end
133137
end
134138
map!(z -> scaler(z, min_x, max_x), locs_x, locs_x)
135139
map!(z -> scaler(z, min_y, max_y), locs_y, locs_y)

0 commit comments

Comments
 (0)