例如以下代码,作图代码最后多了一行a = 1
,结果就不能输出图片了。Julia的这种特性是何苦呢?怎么能让它像matlab一样,运行结束,所有图都保留?
import LinearAlgebra
import Plots
import Random
Random.seed!(314)
# number of clients
m = 12
# number of facility locations
n = 5
# Clients' locations
Xc, Yc = rand(m), rand(m)
# Facilities' potential locations
Xf, Yf = rand(n), rand(n)
# Distance
c = zeros(m, n)
for i in 1:m
for j in 1:n
c[i, j] = LinearAlgebra.norm([Xc[i] - Xf[j], Yc[i] - Yf[j]], 2)
end
end
Plots.scatter(
Xc,
Yc;
label = "Clients",
markershape = :circle,
markercolor = :blue,
)
Plots.scatter!(
Xf,
Yf;
label = "Facility",
markershape = :square,
markercolor = :white,
markersize = 6,
markerstrokecolor = :red,
markerstrokewidth = 2,
)
a = 1