From paul at stat.auckland.ac.nz  Tue May 16 03:53:14 2017
From: paul at stat.auckland.ac.nz (Paul Murrell)
Date: Tue, 16 May 2017 13:53:14 +1200
Subject: [Rd] Error messages in replayPlot()
In-Reply-To: <CABFfbXtAaM0O0dtFFdLYBk40w1ADaoUz4UJVMRBOVmfgma6YPA@mail.gmail.com>
References: <CABFfbXtAaM0O0dtFFdLYBk40w1ADaoUz4UJVMRBOVmfgma6YPA@mail.gmail.com>
Message-ID: <bbdb1737-2697-8134-f804-4cc59c0bbc69@stat.auckland.ac.nz>

Hi

The "figure margins too large" message is suppressed on replay because 
that replay code is also played when resizing a graphics device (so if 
it was printed to the console you could get millions of error messages 
as you resized a window) - on replay, the message is drawn on the 
graphics device instead (take a look at the PNG that your second example 
creates), but that is not necessarily easy to access.

Paul

On 16/05/17 00:07, Jeroen Ooms wrote:
> I was wondering if there is something that can be done to improve
> error messages when replaying a recorded plot. For example a graphics
> device that is too small usually results in a helpful error message:
>
>  png(height = 100)
>  plot(1)
>  # Error in plot.new() : figure margins too large
>  dev.off()
>
> However when this happens when replaying a recorded plot, the error
> message is not so helpful.
>
>  myplot <- evaluate::evaluate("plot(1)")[[2]]
>  png(height = 100)
>  replayPlot(myplot)
>  # Error in replayPlot(x) : invalid graphics state
>  dev.off()
>
> A more informative error message that hints at what exactly is invalid
> about the graphics state would be very helpful in this case.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/



[Rd] Error messages in replayPlot()
Paul Murrell