Skip to content

fix color scale

6 messages · Hadley Wickham, Dylan Beaudette, Edzer Pebesma +1 more

#
Paul, this nicely illustrates the power of ggplot2.

In the resulting plot, however, it seems to me that the

+ opts(aspect.ratio = 1)

does not result in the desired effect that 1 m in the x direction equals
1 m in the y direction. Standard plot (asp = 1), and lattice plots (asp
= "iso") have this; what does ggplot2 need?
On 10/31/2010 11:31 AM, Paul Hiemstra wrote:

  
    
#
+ coord_equal()

Or if x and y are long and lat, + coord_map()

Hadley

On Sun, Nov 7, 2010 at 1:55 PM, Edzer Pebesma
<edzer.pebesma at uni-muenster.de> wrote:

  
    
#
Interesting demonstration. However, it seems like sp objects and
spplot are still more efficient at storing / plotting large grids. The
example listed below required over 2 minutes to complete on a 2.4 Ghz
Intel processor. Also, storing the coordinates + data in long format
could easily fill available memory with large rasters. I have found
that storing multiple raster attributes as columns in the @data slot
of a SpatialGridDataFrame object give me flexibility to plot images
with a consistent color scheme, without needing to store the data in
long format. Also with lattice, the plots are generated in a couple of
seconds (500x700 px grid). I would be very interested in knowing how
to make ggplot() any faster.

Cheers!
Dylan

On Sun, Nov 7, 2010 at 11:55 AM, Edzer Pebesma
<edzer.pebesma at uni-muenster.de> wrote:
#
Dylan, I believe that lattice (grid) recently improved the plotting of
rasters quite a bit, by using panel.levelplot.raster instead of
panel.levelplot - some function in grid now renders rasters faster on
devices for which this is optimed.

spplot also has to transform the data to long format, by calling
sp:::spmap.to.lev, which in turn uses a stack method for
SpatialPointsDataFrame objects; this in turn uses stack.data.frame

Bests,
On 11/08/2010 05:00 AM, Dylan Beaudette wrote:

  
    
#
To add to Edzer's answer, I had written this earlier - I just don't
know anything about the way grid/lattice can handle rasters.

The image/grid handling with sp/raster can be fast for two main reasons:

- image.SpatialGridDataFrame now can use rasterImage() to plot grids,
so the graphics-memory footprint is minimized, though the full grid is
still in R memory

- the raster package adds memory-management for grids, reading only
what is required on demand for plotting - I think raster still uses
image() for plotting, but it's only ever reading the required data for
a given level of detail, saving the graphics engine from the full
overhead demanded by image()

Those are good improvements that both provide different implications
for grid/lattice and thereby ggplot images.

Cheers, Mike.

On Mon, Nov 8, 2010 at 5:53 PM, Edzer Pebesma
<edzer.pebesma at uni-muenster.de> wrote:

  
    
#
Ah,

Thanks for the clarification. I'll review the changelog before giving my 
opinions!

Cheers,
Dylan
On Sunday, November 07, 2010, Edzer Pebesma wrote: