[#30426] CGI でグラフを描くときにお勧めのライブラリは? — 堀川 久 <vzw00011@...>

こんにちは。

12 messages 2001/07/01

[#30453] syntax check without execution? — Tanaka Akira <akr@...17n.org>

最近、eRuby のまねごとをしていて、そのなかで Ruby のコードを生成してい

16 messages 2001/07/04
[#30455] Re: syntax check without execution? — matz@... (Yukihiro Matsumoto) 2001/07/04

まつもと ゆきひろです

[#30479] Object#dup — "Shin'ya Adzumi" <adzumi@...>

あづみです。

20 messages 2001/07/05

[#30512] open errno EALREADY triggerd — "Inoue" <inoue@...>

井上です。

16 messages 2001/07/08

[#30514] Ruby module frame work? — Takahiro Kambe <taca@...>

こんにちは。

16 messages 2001/07/09
[#30515] Re: Ruby module frame work? — matz@... (Yukihiro Matsumoto) 2001/07/09

まつもと ゆきひろです

[#30529] InterBase を使用したい — "YOUJI KUROKAWA" <CQE10242@...>

環境

22 messages 2001/07/09

[#30530] Question about script on the book "Ruby nyuumon" — NAWATE Masahiko <agul@...>

縄手@松江と言います。

17 messages 2001/07/09
[#30531] Re: Question about script on the book "Ruby nyuumon" — rubikitch <rubikitch@...> 2001/07/09

From: NAWATE Masahiko <agul@mag.shimane-u.ac.jp>

[#30533] Re: Question about script on the book "Ruby nyuumon" — NAWATE Masahiko <agul@...> 2001/07/09

縄手@松江です。

[#30734] UML クラス図と Ruby の記述についての対応 — Ken-ichi HASHIMOTO <ken@...>

橋本@福井県在住です。

13 messages 2001/07/28

[#30764] int/int => float? — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

50 messages 2001/07/31
[#30767] Re: int/int => float? — keiju@... (石塚圭樹) 2001/07/31

けいじゅ@日本ラショナルソフトウェアです.

[#30768] Re: int/int => float? — matz@... (Yukihiro Matsumoto) 2001/07/31

まつもと ゆきひろです

[#30770] Re: int/int => float? — Take_tk <ggb03124@...> 2001/07/31

たけ(tk)です。

[#30771] Re: int/int => float? — matz@... (Yukihiro Matsumoto) 2001/07/31

まつもと ゆきひろです

[#30785] Re: int/int => float? — Konishi@... (Hiromasa KONISHI) 2001/07/31

 KONISHI Hiromasaです。

[ruby-list:30438] Re: CGI でグラフを描くときにお勧めのライブラリは?

From: masa@...
Date: 2001-07-02 15:23:55 UTC
List: ruby-list #30438
>From: "K.Kodama" <kdm@kobe-kosen.ac.jp>
>Subject: [ruby-list:30431] Re: CGI でグラフを描くときにお勧めのライブラリは?

> ライブラリじゃ無いけど, gnuplot じゃだめ?

gnuplotが使えるなら、多分それが一番簡単だと思います。試しにこん
なクラスをでっちあげてみました。適当に書き換えて使って下さい。
もっと複雑なことがしたければ、Ruby/Gnuplotというのもあります。
(使ったことはありませんが。)

田中昌宏

--- mygp.rb
# usage: ruby mygp.rb [hoge.png]

class MyGnuplot
  # gp = MyGnuplot.new              ---  display on screen.
  # gp = MyGnuplot.new('hoge.png')  ---  output PNG.
  def initialize(file=nil)
    @file = file
    @pipe = IO.popen('gnuplot -persist','w')
    @pipe << "set data style lines\n"
    if @file
      @pipe << <<CMD
set terminal png color
set output '#{@file}'
CMD
    end
  end

  # gp.plot x, y [,title]
  def plot(x,y,title=nil)
    if title
      t = "title '#{title}'" 
    else
      t = ""
    end
    @pipe << "plot '-' #{t}\n"
    [x.size,y.size].min.times{|i| @pipe << "%f %f\n" % [x[i],y[i]]}
    @pipe << "e\n"
    @pipe.flush
  end
end

n = 100
x = Array.new(n)
y = Array.new(n)
y0= 0.0

n.times do |i|
  x[i] = i
  y0  += rand()*4-2
  y[i] = y0
end

gp = MyGnuplot.new(ARGV[0])
gp.plot x,y, 'data'

In This Thread