geosubplot: Adds a plot to an existing plot initialized by geoplot.

Description Usage Arguments Details Value Side Effects See Also Examples

View source: R/geosubplot.R

Description

Adds a plot, of any kind, to the current plot at a location specified by the user.

Usage

1
geosubplot(fun, pos, size = c(2, 2), fill, fillcol, ...)

Arguments

fun

a call to the function to be subplotted. Be sure to call geoplot with new = T.

pos

Position of the plot. Should include \$lat and \$lon, if length(\$lat) = 1 that point will determine the middle of the subplot, if length(\$lat)=2 the points will determine oppesite corners of the subplots position.

size

The width and the height of the plot if length(pos\$lat)=1. Default is 2,2.

fill

If true the background of the subplot area will be filled. Default is F.

fillcol

fill colour, the colour of the background of the subplot area, default is 0 (usually white)

...

The program accepts any parameter that the subplot program will accept.

Details

The geo functions rely on the parameters in options("geopar") for plotting. Every time geoplot is called a new set of geopar is made and the current erased. If you want to change the parameters in the background plot after you call geosubplot you have to save the current geopar before calling geosubplot. When reassigning geopar, the command options(geopar=list(...)) must be used.

When using geosubplot it is important to save these parameters before the subplot is plotted if one wants to make changes to the large plot afterwards.

Value

none

Side Effects

A plot added to the current plot.

See Also

subplot, geoplot, geopar.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
## Not run: 
      #####################################################
      # Example 1                                         #
      #####################################################

      geoplot()
      pos<- list(lat = 63.5,lon=-11.75)
      geosubplot(geoplot(faeroes,pch=" ",country =faeroes,new=T)
                 ,pos,fill=T)
      # Plots the Faeroes on a plot with Iceland. Be sure to
      # use new = T if geoplot is called again.

      #####################################################
      # Example 2                                         #
      #####################################################

      geoplot()
      large.geopar <- geopar             # Parameters saved.
      pos <- list(lat=c(63,64),lon=c(-27,-24))
      geosubplot(geoplot(island, new=T,grid=F,type="l"),pos)

      geotext(65,-18,"subplot")           # Text on subplot.
      small.geopar <- geopar # Parameters for subplot saved.

      # geopar <- large.geopar       # Make big plot active.
      # Unless you are working directly with the .Data dir of the
      # geolibrary this assignment will not work, must use:
      assign("geopar",large.geopar,where=0)

      geotext(65,-18,"Big plot")         # Text on big plot.

      # Another subplot.

      pos <- list(lat=c(63,64),lon=c(-17,-14))
      geosubplot(geoplot(island,new=T,grid=F,type="l"),pos,fill=T)
      # Another subplot drawn.
      geotext(65,-18,"subplot # 2")

      small.geopar.2 <- geopar # parameters for subplot # 2 saved.
      # geopar <- large.geopar # Big plot made active again
      # Same as above, instead use:
      assign("geopar",large.geopar,where=0)

      # See also similar example in geopar.

## End(Not run)

geo documentation built on May 29, 2017, 5:36 p.m.