[R] empty density plot for point pattern in spatstat
adrian.baddeley at uwa.edu.au
Thu Jun 19 08:00:40 CEST 2014
I think I have the solution to the problem
experienced by users of 'spatstat' on Windows machines,
who are finding that plot.im() gives empty colour images.
Short answer: set useRaster=FALSE in the call to plot.im.
spatstat::plot.im calls graphics::image.default with the argument 'useRaster=TRUE' by default.
When useRaster=TRUE, the image is displayed by the function rasterImage from the graphics package.
This is done to improve behaviour on *some* Windows systems.
But, for unknown reasons, this does not work on Windows Server and on a few versions of Windows XP.
On those systems you may need to set useRaster=FALSE to get a plot.
You can also use the command dev.capabilities() to check whether your current device
In the next release of spatstat we will automatically detect this and set appropriate defaults.
Prof Adrian Baddeley FAA
University of Western Australia
From: Christopher W. Ryan [cryan at binghamton.edu]
Sent: Thursday, 19 June 2014 10:29 AM
To: Adrian Baddeley; Pablo Ramón; Rolf Turner
Subject: Re: [R] empty density plot for point pattern in spatstat
Let me just say that the expertise and support on this List is amazing,
and I'm very grateful. I'm learning a lot from your discussions.
I will not be at my problematic machine again until Friday 20 June. I
will take these steps then, and try to provide as many details about the
system as I can. It is Win XP, now R 3.1.0, and (IIRC) spatstat 1.37-0
I do not encounter the problem on Windows 7, R 3.1.0, spatstat 1.36-0
‘Intense Scrutiny’. Nor on Ubuntu 12.04, R 3.1.0, spatstat 1.36-0.
Adrian Baddeley wrote:
> Dear Pablo
> Please provide details of the system you are using (Windows - version? R version? spatstat version?)
> Also, when you issue the plot command, what graphics device are you using?
> [To find out, type dev.cur() after performing the plot, and read the printout]
> Try changing the colour map by running 'example(plot.im)' or
> setting col=grey(seq(0,1,length=32)) in the call to plot.im
> Try setting 'useRaster=FALSE' in the call to plot.im.
> Let me know if any of these work. If not, let's talk on skype
> to figure it out.
> Prof Adrian Baddeley FAA
> University of Western Australia
> From: Pablo Ramón [paramon at utpl.edu.ec]
> Sent: Wednesday, 18 June 2014 9:36 PM
> To: Rolf Turner
> Cc: Christopher W Ryan; R-help; Adrian Baddeley
> Subject: Re: [R] empty density plot for point pattern in spatstat
> Dear Rolf,
> The problem persists with the function plot.im<http://plot.im>(), or plot (density ()), similar to with(bei.extra, plot (elev)). This problem occurs only with my personal machine, to another machine this problem does not occur. However, when I use another function, such kde2d () in the MASS package and perform the plot, the graph is obtained without problem.
> Best wishes
> 2014-06-17 16:23 GMT-05:00 Rolf Turner <r.turner at auckland.ac.nz<mailto:r.turner at auckland.ac.nz>>:
> On 18/06/14 03:49, Christopher W Ryan wrote:
> I upgraded to version 3.1.0 of R, still on Win XP, but that did not
> solve the problem:
> plot(redwood) # works OK
> plot(Kest(redwood)) # works OK
> plot(density(redwood)) # produces an "empty" plot
> # with just the figure border
> # and a thin vertical box for
> the color ramp
> # but no color ramp in it
> Any other ideas? I'd be much obliged.
> I have had an inquiry of this nature previously and sad to say was completely unable to find a solution. I made numerous suggestions to the inquirer, e.g.:
> *looking for a plot.im<http://plot.im>() function masking the "real"
> plot.im<http://plot.im>() function from spatstat
> * cleaning out the global environment
> (.RData) in case there were some "artefacts" hanging around that had an impact on plot.im<http://plot.im>()
> * completely *removing* .RData and starting again,...
> Nothing worked.
> It is very difficult to diagnose a problem like this remotely. If you could find an R guru who was able to come and sit with you at your computer it is ***just possible*** that they could track down what is going wrong.
> However it seems to me that the problem is due to some sort of recalcitrance of the Windoze system and is thus probably insoluble.
> I am cc-ing this to the person who made the previous inquiry. Pablo, have there been any further developments since we last communicated about this problem?
> Rolf Turner
> P. S. BTW Chris: Does plot.im<http://plot.im>() screw up with other images? E.g. what happens if you do
> R. T.
> Mat. Pablo Ramón
> Sección de Ecología
> Departamento de Ciencias Naturales
> Universidad Técnica Particular de Loja (http://www.utpl.edu.ec/)
> Telf. 593 7 2570275 Ext. 2505, 2258
More information about the R-help