On Mon, 20 Feb 2006, Paul Murrell wrote:

[...]

>>    >> x11()
>>    >> plot(rnorm(10))
>>    >> dev.print(png)

>>     Paul> Error in dev.copy(device = function (filename = "Rplot%03d.png", 
>> width =
>>     Paul> 480,  :
>>     Paul> invalid graphics state

> I think the problem is that the width and height of the PNG device is
> being taken (without regard for units) from the X11 device.  So
> approximately 7 inches square screen window gets drawn into
> approximately 7 *pixel* square PNG file and (understandably) R complains
> that there is not enough room for the plot.

Yes, that it how it is documented to work.

> Another workaround is something like ...
>
> dev.print(png, width=480, height=480)

(Just one will do if you want to preserve the aspect ratio.)

> ... and a fix requires making dev.print() smarter so that it figures out
> that it needs to convert width/height from inches to pixels.

I don't think there is a way to do that unambiguously (there is no 
standard way to do the conversion), and in any case dev.print() was passed 
a function, not the name of a function, and so does not in general know 
how it behaves (and your 'png' need not be R's png()).

All we can do is to re-emphasize this on the help page, and add a warning 
if a known bitmap device is detected (possibly inaccurately) by name.

BTW, I think it was perverse to call dev.print() except to do printing.

-- 
Brian D. Ripley,                  [EMAIL PROTECTED]
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

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to