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

Gabor Grothendieck ggrothendieck at gmail.com
Mon Mar 3 20:18:07 CET 2008


There was some discussion a while back of an R pgf driver
for latex.  Is anyone working on that?

On Mon, Mar 3, 2008 at 2:09 PM, Greg Snow <Greg.Snow at imail.org> wrote:
> The gp.plot function has a type option that can either be 'p' for points
> or 'l' for lines, the function is not that complicated, you could easily
> add additional options.
>
> I don't know why your code is not creating the pdf file, you could try
> plotting to the screen first (don't change the output and terminal),
> make sure that the plot is there, then change the output and terminal
> and do a replot to see if that works.
>
> Given that, I agree with the others that gnuplot is probably not the
> best tool for this.  Others have mentioned how to use cmr and other
> fonts within R, or I mentioned the tool for converting a .eps file to a
> .pgf file that when input into LaTeX will use the current fonts.
>
> Gnuplot is a fine program for what it was designed for, but as you want
> more and more sophisticated statistical plots it will become more and
> more frustrating to do them using gnuplot.  Gnuplot was not really
> designed as a statistical tool (more a mathematical one).
>
> I once heard that the difference between a mathematician and a
> statistician is that one knows the difference between a variable and a
> constant and the other one doesn't.  I think the difference between
> mathematicians and statisticians can be seen in the response to the mean
> value theorem:  the mathematician sees it and says "cool, I can compute
> averages using integrals", the statistician sees it and says "cool, I
> can compute integrals using averages".
>
> Hope this helps,
>
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.snow at imail.org
> (801) 408-8111
>
>
>
> > -----Original Message-----
> > From: Louise Hoffman [mailto:louise.hoffman at gmail.com]
> > Sent: Sunday, March 02, 2008 8:48 AM
> > To: Greg Snow
> > Cc: Gabor Csardi; r-help at r-project.org
> > Subject: Re: [R] Make plots with GNUplot. Have anyone tried that?
> >
>
> > > 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()
> >
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list