GnuPlot on OSX

Just finished install Ruby Gnu Plot on MacBook OSX version 10.5.6 (Leopard). This is Ruby module for creating some graph using GNUPlot. Ruby Gnu plot can be downloaded from here.

Ruby Gnu plot will become interface to real GNUPlot, thus we still need to install GNUPlot. Unfortunately, since apple shipped this version of OSX with readline emulation, installation of GNUPlot will be failed. Below is the part where GNUPlot installation failed:

[cc lang=”bash” line_numbers=”no”]
g++ -g -O2 -o gnuplot alloc.o axis.o breaders.o bitmap.o color.o command.o contour.o datafile.o dynarray.o eval.o fit.o gadgets.o getcolor.o graph3d.o graphics.o help.o hidden3d.o history.o internal.o interpol.o matrix.o misc.o mouse.o parse.o plot.o plot2d.o plot3d.o pm3d.o readline.o save.o scanner.o set.o show.o specfun.o standard.o stdfn.o tables.o term.o time.o unset.o util.o util3d.o variable.o version.o -lreadline -lncurses -lz
Undefined symbols:
“_rl_forced_update_display”, referenced from:
_restore_prompt in command.o
“_rl_ding”, referenced from:
_alert in mouse.o
“_history_list”, referenced from:
_write_history_list in history.o
“_rl_complete_with_tilde_expansion”, referenced from:
_rl_complete_with_tilde_expansion$non_lazy_ptr in plot.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [gnuplot] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
[/cc]

GNUPlot will tried to search for ‘real’ readline. We can fix with specified readline as built-in:

[cc lang=”bash” line_numbers=”no”]
$ ./configure –with-readline=builtin
[/cc]

Then make process will finish successfully. Later we can use Ruby GnuPlot for creating some graph:

[cc lang=”ruby” line_numbers=”true” width=”500″]
#!/usr/bin/env ruby

######################################
### Taken from http://rgplot.rubyforge.org/ ###
######################################
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
[/cc]

We still need to have X11 installed (can be installed from OSX DVD installer). Result?!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s