Skip to content

Commit 39e27ad

Browse files
committed
Update plot.jl
1 parent 816106d commit 39e27ad

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/plot.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,19 @@ function gplot(g::AbstractGraph{T},
129129
locs_x = Float64.(locs_x_in)
130130
locs_y = Float64.(locs_y_in)
131131

132+
# Scale to unit square
132133
# Scale data
133134
min_x, max_x = extrema(locs_x)
134135
min_y, max_y = extrema(locs_y)
135-
136-
# Scale to unit square
137-
function scalerunitsquare(z, a, b)
138-
2.0 * ((z - a) / (b - a)) - 1.0
136+
function scaler(z, a, b)
137+
if (a - b) == 0.0
138+
return 0.5
139+
else
140+
return 2.0 * ((z - a) / (b - a)) - 1.0
141+
end
139142
end
140-
map!(z -> scalerunitsquare(z, min_x, max_x), locs_x, locs_x)
141-
map!(z -> scalerunitsquare(z, min_y, max_y), locs_y, locs_y)
143+
map!(z -> scaler(z, min_x, max_x), locs_x, locs_x)
144+
map!(z -> scaler(z, min_y, max_y), locs_y, locs_y)
142145

143146
# Calculate the size of the box
144147
units = UnitBox(-1.2, -1.2, 2.4, 2.4)

0 commit comments

Comments
 (0)