6

Ruby で関数のプロットを作成する最も簡単な方法は何ですか? 特別なグラフィカル ライブラリに関する提案はありますか?

更新: Windows のみ:-(

更新 2:これまでのところ、次の gem が最良の解決策として見つかりましたhttps://github.com/clbustos/rubyvis

4

6 に答える 6

7

可能なオプションはgnuplotありますか?:

require 'gnuplot.rb'
Gnuplot.open { |gp|
    Gnuplot::Plot.new( gp ) { |plot|
        plot.output "testgnu.pdf"
        plot.terminal "pdf colour size 27cm,19cm"

        plot.xrange "[-10:10]"
        plot.title  "Sin Wave Example"
        plot.ylabel "x"
        plot.xlabel "sin(x)"

        plot.data << Gnuplot::DataSet.new( "sin(x)" ) { |ds|
            ds.with = "lines"
            ds.linewidth = 4
        }
        plot.data << Gnuplot::DataSet.new( "cos(x)" ) { |ds|
            ds.with = "impulses"
            ds.linewidth = 4
        }
    }
}
于 2009-10-13T18:02:37.707 に答える
4

他の誰かがこれにつまずいた場合に備えて、次のコードを使用して gnuplot を使用できました。

require 'rubygems'
require 'gnuplot' 

Gnuplot.open do |gp|
  Gnuplot::Plot.new( gp ) do |plot|

    plot.xrange "[-10:10]"
    plot.title  "Sin Wave Example"
    plot.ylabel "x"
    plot.xlabel "sin(x)"

    plot.data << Gnuplot::DataSet.new( "sin(x)" ) do |ds|
      ds.with = "lines"
      ds.linewidth = 4
    end
  end
end

rubygems を要求し、gnuplot に正しい gem 名を使用することが、私にとって重要でした。

于 2011-04-26T17:03:37.457 に答える
1

これは私の頼りになるグラフ作成ライブラリです:SVG :: Graph

于 2009-10-13T17:39:02.577 に答える
0

私はtiogaが本当に好きです。ラテックスで信じられないほど高品質で出版可能なグラフを作成できます。

于 2009-10-13T18:26:55.007 に答える
0

マイクロソフト エクセルがあります。

もしそうなら、Ruby on Windowsのブログや、 win32ole や ruby​​ とタグ付けされた質問が役立つかもしれません。

于 2011-04-26T22:42:55.190 に答える
0

SVG::Graph::Lineを次のように使用します。

require 'SVG/Graph/Line'

  fields = %w(Jan Feb Mar);
  data_sales_02 = [12, 45, 21]
  data_sales_03 = [15, 30, 40]

  graph = SVG::Graph::Line.new({
          :height => 500,
          :width => 300,
    :fields => fields,
  })

  graph.add_data({
          :data => data_sales_02,
    :title => 'Sales 2002',
  })

  graph.add_data({
          :data => data_sales_03,
    :title => 'Sales 2003',
  })

  print "Content-type: image/svg+xml\r\n\r\n";
  print graph.burn();
于 2009-10-15T17:43:36.010 に答える