2

gnuplot gem で XY 座標ボードを描画しようとしていますが、コードを実行すると自動的に閉じてしまいます。私は例をチェックしていて、私はすべてうまくいっていると思います.私の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
4

2 に答える 2

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
于 2013-05-10T17:39:24.270 に答える
0

一時停止コマンドを試しましたか?ネイティブ gnuplot では、pause -1 はユーザーが Enter を押すのを待ちます。

于 2013-05-20T13:20:52.773 に答える