[R] Make plots with GNUplot. Have anyone tried that?

Louise Hoffman louise.hoffman at gmail.com
Sun Mar 2 16:47:48 CET 2008


> There is a very basic interface between R and gnuplot in the TeachingDemos
> package.  Look at the help for gp.plot.
[snip]

This looks mighty interesting =)

Is it possible to plot "with lines" (gnuplot syntex) so all the data
points are connected?

Also is it possible to make it write the output to a pdf file? (I
using the gnuplot cvs which have pdfcairo support)

When I try this, it doesn't write the pdf file. it works with gnuplot cvs.

library(TeachingDemos)
fuelData<-read.table('fuel.csv',header=TRUE, sep=',')
attach(fuelData)
gp.open(where='/usr/local/bin/gnuplot')
gp.send('set terminal pdfcairo font 'cmr10' size 8cm,4.6cm')
gp.send('set output '../figures/q1-raw-data-gp.pdf'')
gp.send('unset key')
gp.send('set xlabel 'rtime'')
gp.send('set ylabel 'FPI'')
gp.send('set xrange [1979:2005]')
gp.plot(rtime,fpi)
gp.send('unset output')
gp.close()



More information about the R-help mailing list