我正在尝试使用gnuplot gem绘制XY coords bord,但是在运行我的代码时它会自动关闭它。我一直在检查这个例子,我认为我做的一切都好,有谁可以帮助我让我的gnuplot窗口更加可见?我一直在尝试睡觉,但无法弄清楚,为什么它仍然失败。
Gnuplot.open do |gp|
# Start a new plot
Gnuplot::Plot.new(gp) do |plot|
plot.title fn
# plot.grid
# Plot each cluster's points
clusters.each do |cluster|
# Collect all x and y coords for this cluster
x = cluster.points.collect {|p| p.x }
y = cluster.points.collect {|p| p.y }
# Plot w/o a title (clutters things up)
plot.data << Gnuplot::DataSet.new([x,y]) do |ds|
ds.notitle
end
end
end
end
答案 0 :(得分:0)
由于没有发布回复,我将传递我使用的方法:输出到图片格式:
# Graph output by running gnuplot pipe
Gnuplot.open do |gp|
# Start a new plot
Gnuplot::Plot.new(gp) do |plot|
plot.title fn
# plot.grid
plot.terminal "gif"
plot.output File.expand_path("../test.gif", __FILE__)
# Plot each cluster's points
clusters.each do |cluster|
# Collect all x and y coords for this cluster
x = cluster.points.collect {|p| p.x }
y = cluster.points.collect {|p| p.y }
# Plot w/o a title (clutters things up)
plot.data << Gnuplot::DataSet.new( [x,y] ) do |ds|
ds.notitle
end
end
end
end
答案 1 :(得分:0)