Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > gnuplot on ruby

Reply
Thread Tools

gnuplot on ruby

 
 
soxinbox
Guest
Posts: n/a
 
      10-21-2005
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:lot.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:ataSet.new( [x, y] ) do |ds|
ds.with = "linespoints"
ds.notitle
end
end
end

any help is appreciated.


 
Reply With Quote
 
 
 
 
Ara.T.Howard
Guest
Posts: n/a
 
      10-21-2005
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:open `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
================================================== =============================

 
Reply With Quote
 
 
 
 
gordon.j.miller@gmail.com
Guest
Posts: n/a
 
      10-21-2005
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:open `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

 
Reply With Quote
 
soxinbox
Guest
Posts: n/a
 
      10-21-2005

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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:open `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.


 
Reply With Quote
 
soxinbox
Guest
Posts: n/a
 
      10-21-2005
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.

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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:open `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
>



 
Reply With Quote
 
Ara.T.Howard
Guest
Posts: n/a
 
      10-21-2005
On Fri, 21 Oct 2005, http://www.velocityreviews.com/forums/(E-Mail Removed) 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:open `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:ATH_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:open 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
================================================== =============================

 
Reply With Quote
 
soxinbox
Guest
Posts: n/a
 
      10-22-2005
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" <(E-Mail Removed)> wrote in message
news(E-Mail Removed) oaa.gov...
> On Fri, 21 Oct 2005, (E-Mail Removed) 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:open `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:ATH_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:open 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
> ================================================== =============================
>



 
Reply With Quote
 
Edwin
Guest
Posts: n/a
 
      10-22-2005
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/


 
Reply With Quote
 
Patrick Hurley
Guest
Posts: n/a
 
      10-22-2005
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


 
Reply With Quote
 
gordon.j.miller@gmail.com
Guest
Posts: n/a
 
      10-24-2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to call gnuplot from ruby? Pen Ttt Ruby 7 06-01-2010 04:31 PM
new ruby gnuplot Roger Pack Ruby 3 07-16-2009 10:12 PM
Gnuplot with ruby - unset variable? M3tr0 G33k Ruby 7 07-16-2008 11:36 PM
ruby, gnuplot, x11 Joel VanderWerf Ruby 0 03-04-2008 10:39 PM
Ruby-Gnuplot problem (using Cygwin) Nuralanur@aol.com Ruby 0 06-12-2005 04:29 PM



Advertisments