gnuplot on ruby

Discussion in 'Ruby' started by soxinbox, Oct 21, 2005.

  1. soxinbox

    soxinbox Guest

    I installed gnuplot gem, and I am getting some syntax errors when I try to
    run the samples on the projects web page.

    >ruby test.rb

    c:/programs/ruby/lib/ruby/gems/1.8/gems/gnuplot-2.1/lib/gnuplot.rb:20:in
    `popen': No such file or directory - which gnuplot (Errno::ENOENT)
    from
    c:/programs/ruby/lib/ruby/gems/1.8/gems/gnuplot-2.1/lib/gnuplot.rb:20:in
    `open'
    from test.rb:2
    >Exit code: 1


    my test code is copied directly from the gnuplot ruby project web page
    except the added require 'gnuplot' which is not mentioned in the example. I
    think I am missing something simple here.

    require 'gnuplot'
    Gnuplot.open do |gp|
    Gnuplot::plot.new( gp ) do |plot|

    plot.title "Array Plot Example"
    plot.ylabel "x"
    plot.xlabel "x^2"

    x = (0..50).collect { |v| v.to_f }
    y = x.collect { |v| v ** 2 }

    plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
    ds.with = "linespoints"
    ds.notitle
    end
    end
    end

    any help is appreciated.
    soxinbox, Oct 21, 2005
    #1
    1. Advertising

  2. soxinbox

    Ara.T.Howard Guest

    On Fri, 21 Oct 2005, soxinbox wrote:

    > I installed gnuplot gem, and I am getting some syntax errors when I try to
    > run the samples on the projects web page.
    >
    >> ruby test.rb

    > c:/programs/ruby/lib/ruby/gems/1.8/gems/gnuplot-2.1/lib/gnuplot.rb:20:in
    > `popen': No such file or directory - which gnuplot (Errno::ENOENT)
    > from


    it looks like the code must do

    IO::popen `which gnuplot`

    so either

    - gnuplot is not on your system

    - gnuplot is not in your path

    can you verify both of these? from the shell do

    ~:> which -a gnuplot


    -a
    --
    ===============================================================================
    | email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    | phone :: 303.497.6469
    | anything that contradicts experience and logic should be abandoned.
    | -- h.h. the 14th dalai lama
    ===============================================================================
    Ara.T.Howard, Oct 21, 2005
    #2
    1. Advertising

  3. soxinbox

    Guest

    Ara.T.Howard wrote:
    > On Fri, 21 Oct 2005, soxinbox wrote:
    >
    > > I installed gnuplot gem, and I am getting some syntax errors when I try to
    > > run the samples on the projects web page.
    > >
    > >> ruby test.rb

    > > c:/programs/ruby/lib/ruby/gems/1.8/gems/gnuplot-2.1/lib/gnuplot.rb:20:in
    > > `popen': No such file or directory - which gnuplot (Errno::ENOENT)
    > > from

    >
    > it looks like the code must do
    >
    > IO::popen `which gnuplot`
    >
    > so either
    >
    > - gnuplot is not on your system
    >
    > - gnuplot is not in your path
    >
    > can you verify both of these? from the shell do
    >
    > ~:> which -a gnuplot
    >


    Ara is completely correct with his diagnosis. You have two choices,
    either ensure that gnuplot is in your path or hardcode the path in the
    gnuplot.rb file. I've struggled for a number of years on how to
    improvie this but haven't been able to come up with something better
    that satisfies my sense of right and wrong. Suggestions would be
    appreciated.

    Gordon
    , Oct 21, 2005
    #3
  4. soxinbox

    soxinbox Guest

    <> wrote in message
    news:...
    > Ara.T.Howard wrote:
    >> On Fri, 21 Oct 2005, soxinbox wrote:
    >>
    >> > I installed gnuplot gem, and I am getting some syntax errors when I try
    >> > to
    >> > run the samples on the projects web page.
    >> >
    >> >> ruby test.rb
    >> > c:/programs/ruby/lib/ruby/gems/1.8/gems/gnuplot-2.1/lib/gnuplot.rb:20:in
    >> > `popen': No such file or directory - which gnuplot (Errno::ENOENT)
    >> > from

    >>
    >> it looks like the code must do
    >>
    >> IO::popen `which gnuplot`
    >>
    >> so either
    >>
    >> - gnuplot is not on your system
    >>
    >> - gnuplot is not in your path
    >>
    >> can you verify both of these? from the shell do
    >>
    >> ~:> which -a gnuplot
    >>

    >
    > Ara is completely correct with his diagnosis. You have two choices,
    > either ensure that gnuplot is in your path or hardcode the path in the
    > gnuplot.rb file. I've struggled for a number of years on how to
    > improvie this but haven't been able to come up with something better
    > that satisfies my sense of right and wrong. Suggestions would be
    > appreciated.
    >
    > Gordon
    >

    Aha! I see it now. The problem isn't that gnuplot isn't in the path, but
    that 'which' is not a standard command on windows XP.
    I guess not many people have tried running this under windows.
    soxinbox, Oct 21, 2005
    #4
  5. soxinbox

    soxinbox Guest

    gordon, It looks like the gnuplot executable on windows needs to be
    pgnuplot.exe. Might I suggest that when on windows you set cmd = "pgnuplot"
    and assume it is in the path. I don't know the ruby way to check for
    platform, perhaps ENV["OS"].downcase.include?("win") or some such hack.

    <> wrote in message
    news:...
    > Ara.T.Howard wrote:
    >> On Fri, 21 Oct 2005, soxinbox wrote:
    >>
    >> > I installed gnuplot gem, and I am getting some syntax errors when I try
    >> > to
    >> > run the samples on the projects web page.
    >> >
    >> >> ruby test.rb
    >> > c:/programs/ruby/lib/ruby/gems/1.8/gems/gnuplot-2.1/lib/gnuplot.rb:20:in
    >> > `popen': No such file or directory - which gnuplot (Errno::ENOENT)
    >> > from

    >>
    >> it looks like the code must do
    >>
    >> IO::popen `which gnuplot`
    >>
    >> so either
    >>
    >> - gnuplot is not on your system
    >>
    >> - gnuplot is not in your path
    >>
    >> can you verify both of these? from the shell do
    >>
    >> ~:> which -a gnuplot
    >>

    >
    > Ara is completely correct with his diagnosis. You have two choices,
    > either ensure that gnuplot is in your path or hardcode the path in the
    > gnuplot.rb file. I've struggled for a number of years on how to
    > improvie this but haven't been able to come up with something better
    > that satisfies my sense of right and wrong. Suggestions would be
    > appreciated.
    >
    > Gordon
    >
    soxinbox, Oct 21, 2005
    #5
  6. soxinbox

    Ara.T.Howard Guest

    On Fri, 21 Oct 2005, wrote:

    > Ara.T.Howard wrote:
    >> On Fri, 21 Oct 2005, soxinbox wrote:
    >>
    >>> I installed gnuplot gem, and I am getting some syntax errors when I try to
    >>> run the samples on the projects web page.
    >>>
    >>>> ruby test.rb
    >>> c:/programs/ruby/lib/ruby/gems/1.8/gems/gnuplot-2.1/lib/gnuplot.rb:20:in
    >>> `popen': No such file or directory - which gnuplot (Errno::ENOENT)
    >>> from

    >>
    >> it looks like the code must do
    >>
    >> IO::popen `which gnuplot`
    >>
    >> so either
    >>
    >> - gnuplot is not on your system
    >>
    >> - gnuplot is not in your path
    >>
    >> can you verify both of these? from the shell do
    >>
    >> ~:> which -a gnuplot
    >>

    >
    > Ara is completely correct with his diagnosis. You have two choices, either
    > ensure that gnuplot is in your path or hardcode the path in the gnuplot.rb
    > file. I've struggled for a number of years on how to improvie this but
    > haven't been able to come up with something better that satisfies my sense
    > of right and wrong. Suggestions would be appreciated.


    maybe somthing like (un-tested):

    def which bin
    path = ENV['PATH'] # || ENV['WHAT_EVER_WINDOWS_PATH_VAR_IS']
    path.split(File::pATH_SEPARATOR).each do |dir|
    candidate = File::join dir, bin
    return candidate if File::executable? candidate
    end
    return nil
    end

    gnuplot = ENV['RB_GNUPLOT'] || 'gnuplot'

    gnuplot = which gnuplot or raise 'gnuplot is not in your path'

    or, if windows isn't a concern

    gnuplot = `which gnuplot`

    raise 'gnuplot not in your path' unless $? == 0

    IO::popen gnuplot


    thanks for the good work on gnuplot btw - i've used in many times.

    cheers.

    -a
    --
    ===============================================================================
    | email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    | phone :: 303.497.6469
    | anything that contradicts experience and logic should be abandoned.
    | -- h.h. the 14th dalai lama
    ===============================================================================
    Ara.T.Howard, Oct 21, 2005
    #6
  7. soxinbox

    soxinbox Guest

    You will have to add something to change the search to look for pgnuplot.exe
    as there is no gnuplot.exe on windows. I have just started using this, but I
    agree it looks cool. I hope to use it to output some technical graphs.
    Thanks to those that created gnuplot and the ruby adaptation layer.

    "Ara.T.Howard" <> wrote in message
    news:p...
    > On Fri, 21 Oct 2005, wrote:
    >
    >> Ara.T.Howard wrote:
    >>> On Fri, 21 Oct 2005, soxinbox wrote:
    >>>
    >>>> I installed gnuplot gem, and I am getting some syntax errors when I try
    >>>> to
    >>>> run the samples on the projects web page.
    >>>>
    >>>>> ruby test.rb
    >>>> c:/programs/ruby/lib/ruby/gems/1.8/gems/gnuplot-2.1/lib/gnuplot.rb:20:in
    >>>> `popen': No such file or directory - which gnuplot (Errno::ENOENT)
    >>>> from
    >>>
    >>> it looks like the code must do
    >>>
    >>> IO::popen `which gnuplot`
    >>>
    >>> so either
    >>>
    >>> - gnuplot is not on your system
    >>>
    >>> - gnuplot is not in your path
    >>>
    >>> can you verify both of these? from the shell do
    >>>
    >>> ~:> which -a gnuplot
    >>>

    >>
    >> Ara is completely correct with his diagnosis. You have two choices,
    >> either
    >> ensure that gnuplot is in your path or hardcode the path in the
    >> gnuplot.rb
    >> file. I've struggled for a number of years on how to improvie this but
    >> haven't been able to come up with something better that satisfies my
    >> sense
    >> of right and wrong. Suggestions would be appreciated.

    >
    > maybe somthing like (un-tested):
    >
    > def which bin
    > path = ENV['PATH'] # || ENV['WHAT_EVER_WINDOWS_PATH_VAR_IS']
    > path.split(File::pATH_SEPARATOR).each do |dir|
    > candidate = File::join dir, bin
    > return candidate if File::executable? candidate
    > end
    > return nil
    > end
    >
    > gnuplot = ENV['RB_GNUPLOT'] || 'gnuplot'
    >
    > gnuplot = which gnuplot or raise 'gnuplot is not in your path'
    >
    > or, if windows isn't a concern
    >
    > gnuplot = `which gnuplot`
    >
    > raise 'gnuplot not in your path' unless $? == 0
    >
    > IO::popen gnuplot
    >
    >
    > thanks for the good work on gnuplot btw - i've used in many times.
    >
    > cheers.
    >
    > -a
    > --
    > ===============================================================================
    > | email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    > | phone :: 303.497.6469
    > | anything that contradicts experience and logic should be abandoned.
    > | -- h.h. the 14th dalai lama
    > ===============================================================================
    >
    soxinbox, Oct 22, 2005
    #7
  8. soxinbox

    Edwin Guest

    While we are on the topic off rgnuplot, does anybody know if it is =20
    possible to still "turn" 3d graphs when called from ruby. If I make a =20
    graph directly in gnuplot I can spin it around with the mouse to look at =
    =20
    it from different sides. With rgnuplot that doesn't seem possible.

    (This is on linux)

    Edwin

    --=20
    Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
    Edwin, Oct 22, 2005
    #8
  9. Another FYI, I have found that under windows, the gnuplot from cygwin
    is actually better than the native pgnuplot, for handling piped input
    (and cygwin will also fix the missing which issue).

    pth
    Patrick Hurley, Oct 22, 2005
    #9
  10. soxinbox

    Guest

    I'm not too familiar with the interactive gnuplot capabilities (I
    stepped out of gnuplot development around this time and don't really
    care about the interactive part). When the plot window is up it is
    being executed from within gnuplot so it should respond the exact same
    as it would interactively.
    , Oct 24, 2005
    #10
  11. soxinbox

    Guest

    Sorry for the delay in replying, I only participate in the digest mode.

    I'll put something like Ara mentioned into the codebase and put a new
    release out within the next week. Thanks for the good suggestions.

    Gordon
    , Oct 24, 2005
    #11
  12. soxinbox

    Guest

    Am Samstag, 22. Oktober 2005 11:49:32 UTC+2 schrieb Edwin:
    > While we are on the topic off rgnuplot, does anybody know if it is
    > possible to still "turn" 3d graphs when called from ruby. If I make a
    > graph directly in gnuplot I can spin it around with the mouse to look at
    > it from different sides. With rgnuplot that doesn't seem possible.
    >
    > (This is on linux)
    >
    > Edwin
    >
    > --
    > Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


    Hi Edwin,

    can you please tell me how to generate 3d graphs using rgnuplot?

    I'm trying this for a few days.

    Thanks, steve
    , Dec 18, 2012
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    131
  2. Joel VanderWerf

    ruby, gnuplot, x11

    Joel VanderWerf, Mar 4, 2008, in forum: Ruby
    Replies:
    0
    Views:
    134
    Joel VanderWerf
    Mar 4, 2008
  3. M3tr0 G33k

    Gnuplot with ruby - unset variable?

    M3tr0 G33k, Jul 7, 2008, in forum: Ruby
    Replies:
    7
    Views:
    330
    Philip Rutkowski
    Jul 17, 2008
  4. Roger Pack

    new ruby gnuplot

    Roger Pack, Jul 16, 2009, in forum: Ruby
    Replies:
    3
    Views:
    122
    Joel VanderWerf
    Jul 16, 2009
  5. Pen Ttt

    how to call gnuplot from ruby?

    Pen Ttt, May 27, 2010, in forum: Ruby
    Replies:
    7
    Views:
    196
    Joel VanderWerf
    Jun 1, 2010
Loading...

Share This Page