[R] plot problem

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Aug 20 23:13:22 CEST 2006


On Sun, 20 Aug 2006, Daniil Ivanov wrote:

> Hello.
> 
> I'm pretty much new to R and I'm trying to produce some figures.

What have you been reading to get the ideas below?  People new to R do not 
tend to use dev.next ... indeed experienced users very rarely use it.

> It seems to me, that R has some asynchronous way of plotting figures.
> When I run this code:

It will not run for us: please see the posting guide.  You have forgotten 
to load some package here, and there are variogram() functions in at least 
packages gstat and spatial so we can't even tell what.

> #constructs the semivariogram of SC1929
> vgm1 <- variogram(SC1929~1,~U+V,puerto.map$att.data)
> 
> # trying to make new plot
> dev.set(which=dev.next())

What do think that does?  It seems to say you want to plot on the null 
device, since no next device has been set.

> plot(vgm1)
> title(main="Semivariogram",font.main=4)
> dev.copy2eps(file="fig2.eps",horizontal=T)
> dev.off()
> 
> R complains that
> Error in title(main = "Semivariogram", font.main = 4) :
>         plot.new has not been called yet
> 
> So that plot(..) hasn't been executed before call of title.

That is _not_ what it says.  A guess is that this is a lattice plot from 
package gstat, in which case plot.new has indeed not been called.

> The most weird about that, if I add fix(vgm1) before
> dev.set(...), everything is just fine. Why R can't just
> perform commands one by one?

It does.  You cannot use title() to annotate a lattice plot, though.

> P.S. I use Linux version of R.
> 
> Thanks, Daniil.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.

PLEASE do as it asks.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list