[R] Creating smooth color regions with panel.contourplot()

Deepayan Sarkar deepayan.sarkar at gmail.com
Wed Sep 17 22:44:47 CEST 2008


On Wed, Sep 17, 2008 at 1:25 PM, Deepayan Sarkar
<deepayan.sarkar at gmail.com> wrote:
> On Wed, Sep 17, 2008 at 1:12 PM, David Carslaw
> <d.c.carslaw at its.leeds.ac.uk> wrote:
>>
>> I think this is a very useful function that I imagine has wide appeal -
>> thanks.  Using the code below produces the plot OK but when I try and
>> copy/save it (as a metafile) I receive the following error and an hourglass:
>>
>> Error: invalid graphics state
>>
>> [using XP, 2.72, lattice 0.17.13]
>
> Yes, that's the drawback of mixing grid and base graphics (even
> resizing the screen device will not work). However, if you explicitly
> start a device and plot to it, instead of copying from a screen
> device, that should work fine.

That isn't completely accurate. To ensure that the plot doesn't start
a new page, you need something like

pdf()
plot.new()
levelplot(volcano, panel = panel.filledcontour,
          col.regions = terrain.colors,
          cuts = 25,
          plot.args = list(newpage = FALSE))
dev.off()

-Deepayan



More information about the R-help mailing list