Commit fbca97fb authored by Burkhardt Rockel's avatar Burkhardt Rockel

-------------------------

* Introduce rdoxygen2 commands in the R functions for easier and cleaner contruction of the documentation.
*
* Include the possibility to plot results from the ICON model.
* Replaced fixed variable names like HSURF and FR\_LAND by their CF standard\_name.
parent 77ec7453
File added
^.*\.Rproj$
^\.Rproj\.user$
ncdf4Utils.Rproj
.Rproj.user
.Rhistory
.RData
.Ruserdata
src/*.o
src/*.so
src/*.dll
Package: ncdf4Utils
Version: 2.1.4
Date: 2018-04-12
Version: 3.0
Date: 2019-03-07
Title: Provides plot functions to use with NetCDF data
Authors@R: c(
person("Burkhardt", "Rockel", "email=burkhardt.rockel@hzg.de", role = c("aut", "cre")),
person("Ronny", "Petrik", "email=ronny.petrik@hzg.de", role = "aut"))
Author: Burkhardt Rockel [aut,cre],
Jonas Bhend [aut],
Ronny Petrik [aut]
Maintainer: Burkhardt Rockel <burkhardt.rockel@hzg.de>
Depends: R (>= 3.4.4), ncdf4, maps, mapdata, sp, akima
Suggests: PCICT
Description: This package contains numerous functions to plot
spatial data on rotated and other grids following the CF conventions.
person("Burkhardt", "Rockel", email="burkhardt.rockel@hzg.de", role = c("aut", "cre")),
person("Jonas", "Bhend", role = "aut"),
person("Ronny", "Petrik", role = "ctb"))
URL: https://git.coast.hzg.de/burkhardt.rockel/ncdf4Utils
BugReports: https://git.coast.hzg.de/burkhardt.rockel/ncdf4Utils/issues
Depends: R (>= 3.4.4)
Imports: ncdf4, maps, mapdata, sp, akima, PCICt
Description: This package contains numerous functions to plot spatial data
on rotated and other grids in netCDF format following the CF conventions.
License: GPL
LazyLoad: yes
LazyData: true
Packaged: 2018-04-12 09:00:00 UTC; rockel
Packaged: 2019-03-07 15:00:00 UTC; rockel
RoxygenNote: 6.1.1
exportPattern("^[^\\.]")
useDynLib(ncdf4Utils)
# Generated by roxygen2: do not edit by hand
export(frac_in_polygon)
export(geo2mod)
export(geo2rot)
export(get_ethz_palette)
export(get_ncar_palette)
export(nccf_times)
export(plot_colourbar)
export(plotmap)
export(polymask)
export(rbfun)
export(set_position)
export(shaded_contour)
export(windvec)
ncdf4Utils version 2.1.4
# ncdf4Utils version 3.0
-------------------------
correct error in plotmap.R in case option levs are given but cols not
* Introduce rdoxygen2 commands in the R functions for easier and cleaner contruction of the documentation.
*
* Include the possibility to plot results from the ICON model.
* Replaced fixed variable names like HSURF and FR\_LAND by their CF standard\_name.
ncdf4Utils version 2.1.3
# ncdf4Utils version 2.1.4
-------------------------
correct bug in plotting flag_values and flag_meanings
* correct error in plotmap.R in case option levs are given but cols not
# ncdf4Utils version 2.1.3
-------------------------
* correct bug in plotting flag\_values and flag\_meanings
affected modules:
plotmap.R
plot_colourbar.R
* plotmap.R
* plot_colourbar.R
ncdf4Utils version 2.1.2
# ncdf4Utils version 2.1.2
-------------------------
correct bug for plotting wrong right triangle color in the color bar plot_colourbar.R
ncdf4Utils version 2.1.1
# ncdf4Utils version 2.1.1
-------------------------
v2.1.1 2018/01/15
Correct the DESCRIPTION file
ncdf4Utils version 2.1
# ncdf4Utils version 2.1
-------------------------
Removed: plotmap.old.R
Replaced: ncdf_times.R by nccf_times.R
Replaced: ncdf\_times.R by nccf\_times.R
In colfun.R
......@@ -43,7 +53,7 @@ In windvec.R
added new option legend.scale
ncdf4Utils version 2.0
# ncdf4Utils version 2.0
-------------------------
**Changed functions:**
......@@ -89,7 +99,7 @@ ncdf4Utils version 2.0
The old version of the function `plotmap` is now called `plotmap.old`. This function will stay as is and will not be further developped.
ncdf4Utils version 1.1
# ncdf4Utils version 1.1
-------------------------
**Changed functions:**
......@@ -99,7 +109,7 @@ ncdf4Utils version 1.1
* corrected a bug preventing sea color to be blue by default
* new parameter "smoothed". If set to "T" the plot will be smoothed.
ncdf4Utils version 1.0
# ncdf4Utils version 1.0
-------------------------
**Changed functions:**
......@@ -116,7 +126,7 @@ ncdf4Utils version 1.0
* creates a mask file from a given polygon
ncdf4Utils version 0.5-3
# ncdf4Utils version 0.5-3
-------------------------
**Changed functions:**
......@@ -130,7 +140,7 @@ ncdf4Utils version 0.5-3
* Introduced new paramenter "pollonshift" to account for pollat=90, pollon=180 (TRUE, default)and pollat=90, pollon=0 (FALSE) representing rotated == geographical grid
* Corrected error in case pollat=90, pollon /= 0., pollonshift=FALSE
ncdf4Utils version 0.5-2
# ncdf4Utils version 0.5-2
-------------------------
**Changed functions:**
......@@ -152,7 +162,7 @@ ncdf4Utils version 0.5-2
* Missing reading of attribute earth_radius for multiple_rotated_pole transformation added
* Distinguish for 3D variables whether the third dimension is time or level
ncdf4Utils version 0.5-1
# ncdf4Utils version 0.5-1
-------------------------
**Removed functions:**
......@@ -184,7 +194,7 @@ ncdf4Utils version 0.5-1
* Transforms geographical to multiple rotated pole coordinates (usage: geo2multirot) or multiple rotated pole to geographical coordinates (usage: multirot2geo)
ncdf4Utils version 0.4-10
# ncdf4Utils version 0.4-10
-------------------------
initial version in netCDF4 based on netCDF3 version ncdfUtils
......
#' Several functions dealing with colors
#'
#' Creating different kind of color bars
#'
#' @param x Number of colours
#' @param start starting point (0 is black, 1 is white)
#' @param log logarithmic scaling (more difference in light colours)
#'
#' @return a vector of rgb colours in R colour format
#'
#' @author Jonas Bhend
#'
#' @examples
#' image(array(1:9, c(1,9)), breaks=0.5 + 0:9, col=rbfun(9), axes=F, xlab="", ylab="")
#'
#' @export
#' @describeIn rbfun computes a symmetric redblue color scale with x colors
rbfun <- function(x, start=0.4, log=F){
# rbfun computes a symmetric redblue color scale with x colors
#
# Arguments:
# x number of colors
# start 'Darkness' of the darkest colours (0=black, 1=white)
# log logical, defaults to FALSE, if true, colors around the
# center of the color scale get brighter
#
# Author jonas.bhend
#
numx <- floor(x/2)
if (2*numx == x){
colour <- c(.colseq((numx+1), .bluewhite, start=start, log=log)[1:numx],
rev(.colseq((numx+1), .redwhite, start=start, log=log)[1:numx]))
} else {
colour <- c(.colseq((numx+1), .bluewhite, start=start, log=log),
rev(.colseq((numx+1), .redwhite, start=start, log=log)[1:numx]))
}
colour
}
#' @describeIn rbfun computes a symmetric greenbrown color scale with x colors
gbfun <- function(x, start=0.4, log=F){
# rbfun computes a symmetric greenbrown color scale with x colors
#
# Arguments:
# x number of colors
# start 'Darkness' of the darkest colours (0=black, 1=white)
# log logical, defaults to FALSE, if true, colors around the
# center of the color scale get brighter
#
# Author jonas.bhend
#
numx <- floor(x/2)
if (2*numx == x){
colour <- c(.colseq((numx+1), .brownwhite, start=start, log=log)[1:numx],
rev(.colseq((numx+1), .greenwhite, start=start, log=log)[1:numx]))
} else {
colour <- c(.colseq((numx+1), .brownwhite, start=start, log=log),
rev(.colseq((numx+1), .greenwhite, start=start, log=log)[1:numx]))
}
colour
}
.data <- t(array(c(
0, 0, 0,
2, 31, 64,
......@@ -110,81 +173,5 @@ rm(.data)
colour
}
rbfun <- function(x, start=0.4, log=F){
# rbfun computes a symmetric redblue color scale with x colors
#
# Arguments:
# x number of colors
# start 'Darkness' of the darkest colours (0=black, 1=white)
# log logical, defaults to FALSE, if true, colors around the
# center of the color scale get brighter
#
# Author jonas.bhend -at- gkss.de
#
numx <- floor(x/2)
if (2*numx == x){
colour <- c(.colseq((numx+1), .bluewhite, start=start, log=log)[1:numx],
rev(.colseq((numx+1), .redwhite, start=start, log=log)[1:numx]))
} else {
colour <- c(.colseq((numx+1), .bluewhite, start=start, log=log),
rev(.colseq((numx+1), .redwhite, start=start, log=log)[1:numx]))
}
colour
}
gbfun <- function(x, start=0.4, log=F){
# rbfun computes a symmetric greenbrown color scale with x colors
#
# Arguments:
# x number of colors
# start 'Darkness' of the darkest colours (0=black, 1=white)
# log logical, defaults to FALSE, if true, colors around the
# center of the color scale get brighter
#
# Author jonas.bhend -at- gkss.de
#
numx <- floor(x/2)
if (2*numx == x){
colour <- c(.colseq((numx+1), .brownwhite, start=start, log=log)[1:numx],
rev(.colseq((numx+1), .greenwhite, start=start, log=log)[1:numx]))
} else {
colour <- c(.colseq((numx+1), .brownwhite, start=start, log=log),
rev(.colseq((numx+1), .greenwhite, start=start, log=log)[1:numx]))
}
colour
}
.soil <- c("#E6FAFF","white", "grey", gbfun(6)[c(3:1,4:6)], .water)
get.ethz.palette <-
function(palette.name, url="https://wiki.c2sm.ethz.ch/pub/Data/VisNCLCosmoLibraryColorTables/")
{
file<-paste(url,palette.name,".ct",sep="")
urlcolors<-readLines(file)
urlcolors<-urlcolors[!startsWith(urlcolors,';')]
n.lines<-length(urlcolors)
n.levels<-as.numeric(urlcolors[1])
levels<-as.numeric(scan(text=urlcolors[2], what="",quiet=TRUE))
colors<-c(1:(n.levels+1))
for (i in 1:(n.levels+1)) {
colors.rgb <- as.numeric(scan(text=urlcolors[i+2], what="",quiet=TRUE))
colors[i] <- rgb(colors.rgb[1],colors.rgb[2],colors.rgb[3], maxColorValue=255)
}
out<-list(colors=colors, levels=levels)
}
get.ncar.palette <-
function(palette.name, url="http://www.ncl.ucar.edu/Document/Graphics/ColorTables/Files/")
{
file<-paste(url,palette.name,".rgb",sep="")
urlcolors<-readLines(file)
urlcolors<-urlcolors[urlcolors!="" & !startsWith(urlcolors,'#')]
n.colors<-as.numeric(strsplit(x = urlcolors[1], split = "=", fixed = T)[[1]][2])
colors<-c(1:n.colors)
for (i in 1:(n.colors)) {
colors.rgb <- as.numeric(scan(text=urlcolors[i+1], what="",quiet=TRUE))
colors[i] <- rgb(colors.rgb[1],colors.rgb[2],colors.rgb[3], maxColorValue=255)
}
out<-list(colors=colors)
}
#' Function to compute what fraction of grid cells lies within the given polygon
#'
#' This function computes for a regular grid (one vector of longitudes and latitudes), what fraction of each grid cell lies within the given polygon.
#'
#' @param lon A vector of grid longitudes
#' @param lat A vector of grid latitudes
#' @param poly.x The longitudes of the edges of the polygon
#' @param poly.y The latitudes of the edges of the polygon
#' @param multiply Factor by which the grid is inflated for computation
#'
#' @return Returns a matrix of dimension nlon x nlat of fractional gridbox area within the polygon
#'
#' @details The accuracy for this method scales with the multiplying factor. After inflation, grid points within the polygon are found with \code{point.in.polygon} from the package \code{sp}
#'
#' @author Jonas Bhend
#'
#' @seealso \code{\link[sp]{point.in.polygon}}
#'
#' @examples
#' # set up latitudes and longitudes
#' lon <- seq(-3.5,3.5,0.5)
#' lat <- seq(-3.5,3.5,0.5)
#' # polygon is a circle with radius 3
#' poly.x <- 3*sin(seq(0,2*pi,length=100))+0.13
#' poly.y <- 3*cos(seq(0,2*pi,length=100))-0.32
#' outgrid <- frac_in_polygon(lon,lat,poly.x,poly.y, multiply=5)
#' # plot the result
#' image(lon,lat,outgrid, asp=1)
#' lines(poly.x, poly.y, lwd=2)
#'
#' @export
`frac_in_polygon` <-
function(lon, lat, poly.x, poly.y, multiply=4){
......
#' Function to convert geographical into model coordinates
#'
#' Functions to converts geographical latitudes and longitudes to positions on a regular model grid.
#'
#'
#' @param lon geographical longitudes of the model grid points, a vector or a matrix
#' @param lat geographical latitudes of the model grid points, a vector or a matrix
#' @param ptlon geographical longitude values to be converted, a vector with the same length as ptlat
#' @param ptlat geographical longitude values to be converted, a vector with the same length as ptlon
#' @param gridmapping A list of attributes for the grid mapping as it is returned by the plotmap function
#'
#' @return Returns a list with two vectors:
#' \item{x}{Processed longitudes}
#' \item{y}{Processed latitudes}
#'
#' @note This function does not work for unstructured grid
#'
#' @author Burkhardt Rockel (HZG)
#'
#' @examples
#' # for rotated coordinates
#'
#' tmp <- plotmap(...)
#' point<- geo2mod(lon, lat, c(10.,30.,-40.), c(50.,60.,60.),gridmapping=tmp$gridmapping)
#'
#' # for all other coordinates
#' tmp <- plotmap(...)
#' point<- geo2mod(lon, lat, c(10.,30.,-40.), c(50.,60.,60.),gridmapping=list(attribute1=NULL))
#'
#' @export
geo2mod <- function(lon,lat,ptlon,ptlat, gridmapping=list(attribute1=NULL)) {
npt = length(ptlon)
......
......@@ -238,6 +238,34 @@
##########################################################
#' Functions to convert geographic to rotated coordinates and vice versa
#'
#' Functions to convert rotated latitudes and longitudes to positions on regular grids and vice versa
#'
#' @param pollon Longitude of the rotated pole in degrees
#' @param pollat Latitude of the rotated pole in degrees
#' @param polgam Rotation angle about the North-South-Pole axis in the rotated system
#' @param lon A vector of longitudes
#' @param lat A vector of latitudes
#' @param rlon A vector of longitudes on the rotated grid
#' @param rlat A vector of latitudes on the rotated grid
#'
#' @return Returns a list with two vectors:
#' \item{x}{Processed longitudes}
#' \item{y}{Processed latitudes}
#'
#' @note These functions are based on the respective fortran code from the COSMO model (numerical weather prediction model of the DWD, Germany).
#'
#' @author Jonas Bhend
#'
#' @examples
#' Location of c(0,0) in rotated coordinates
#' rot2geo(-170, 32.5, 0, 0)
#'
#' @export
#' @describeIn geo2rot convert regular lat/lon to rotated grid
geo2rot <- function(pollon, pollat, lon, lat, polgam=0, pollonshift=TRUE){
rlon <- .rla2rlarot(lat, lon, pollat, pollon, polgam, pollonshift)
......@@ -249,6 +277,7 @@ geo2rot <- function(pollon, pollat, lon, lat, polgam=0, pollonshift=TRUE){
##########################################################
#' @describeIn geo2rot convert rotated to regular lat/lon grid
rot2geo <- function(pollon, pollat, rlon, rlat, polgam=0, pollonshift=TRUE){
lon <- .rlarot2rla(rlat, rlon, pollat, pollon, polgam, pollonshift)
......
#' Function to get a palette from the ETHZ web site
#'
#' The functions retrieves a palette from the ETHZ web site
#' https://wiki.c2sm.ethz.ch/pub/Data/VisNCLCosmoLibraryColorTables/
#'
#' @param palette.name Name of the palette as listed on the ETHZ web site
#' @param url url of the ETHZ palette web site
#'
#' @return A list variable with
#' \item{colors}{The colours of the palette}
#' \item{levels}{An example of levels}
#'
#' @author Burkhardt Rockel (HZG)
#'
#' @export
get_ethz_palette <-
function(palette.name, url="https://wiki.c2sm.ethz.ch/pub/Data/VisNCLCosmoLibraryColorTables/")
{
file<-paste(url,palette.name,".ct",sep="")
urlcolors<-readLines(file)
urlcolors<-urlcolors[!startsWith(urlcolors,';')]
n.lines<-length(urlcolors)
n.levels<-as.numeric(urlcolors[1])
levels<-as.numeric(scan(text=urlcolors[2], what="",quiet=TRUE))
colors<-c(1:(n.levels+1))
for (i in 1:(n.levels+1)) {
colors.rgb <- as.numeric(scan(text=urlcolors[i+2], what="",quiet=TRUE))
colors[i] <- rgb(colors.rgb[1],colors.rgb[2],colors.rgb[3], maxColorValue=255)
}
out<-list(colors=colors, levels=levels)
}
#' Function to get a palette from the NCAR web site
#'
#' The functions retrieves a palette from the ETHZ web site
#' http://www.ncl.ucar.edu/Document/Graphics/ColorTables/Files/
#'
#' @param palette.name Name of the palette as listed on the NCAR web site
#' @param url url of the NCAR palette web site
#'
#' @return A list variable with
#' \item{colors}{The colours of the palette}
#' \item{levels}{An example of levels}
#'
#' @author Burkhardt Rockel (HZG)
#'
#' @export
get_ncar_palette <-
function(palette.name, url="http://www.ncl.ucar.edu/Document/Graphics/ColorTables/Files/")
{
file<-paste(url,palette.name,".rgb",sep="")
urlcolors<-readLines(file)
urlcolors<-urlcolors[urlcolors!="" & !startsWith(urlcolors,'#')]
n.colors<-as.numeric(strsplit(x = urlcolors[1], split = "=", fixed = T)[[1]][2])
colors<-c(1:n.colors)
for (i in 1:(n.colors)) {
colors.rgb <- as.numeric(scan(text=urlcolors[i+1], what="",quiet=TRUE))
colors[i] <- rgb(colors.rgb[1],colors.rgb[2],colors.rgb[3], maxColorValue=255)
}
out<-list(colors=colors)
}
#' Function to extract dates and times from NetCDF file opened with nc_open()
#'
#' This function extracts the date and time information from NetCDF files that follow the CF conventions and converts it either to the internal Date format.
#'
#' @param nc The connection to the netcdf file as with nc_open()
#'
#' @return A vector of Dates or Datetimes depending on the units in the NetCDF file.
#'
#' @note his function assumes that the netCDF is in CF convention, ie. the variable holding the time information must be named "time".
#' The time variable must have a "units" attribute in the form "seconds since YYYY-MM-DD HH:MM:SS" where "seconds" can also be "minutes", "hours", "days", "months", "years"
#'
#' @author Burkhardt Rockel (HZG)
#' @seealso {\code{\link[ncdf4]{nc_open}}, \code{\link{as.PCICt}}}
#' @examples
#' # Open a file and read its data
#' nc <- nc_open("foo.nc")
#' times <- nccf_times(nc)
#' print("here is the data in the file:")
#' head(times)
#' tail(times)
#' t2m <- ncvar_get(nc, "T_2M")
#' nc_close( nc )
#' plot(times, t2m, type="l")
#'
#' @export
`nccf_times` <-
function(nc) {
# this function converts netcdf times in a netCDF file
......
#' Function to plot a colourbar
#'
#' Generic function to plot a horizontal or vertical colourbar with axis on the specified side.
#'
#' @param levs Levels (boundaries)
#' @param cols colours to use
#' @param x.list A list of class "plotmap" containing the levels and colours and additional information as returned by \code{plotmap}
#' @param incl.units allows for the long-name and units attribute of the plotted variable to be added to the axis annotation)
#' @param nn Each nn axis label will be drawn
#' @param side At which side of the image the colour bar will be plottet: 1=bottom 2=left, 3=top, 4=right
#' @param cex.axis The magnification to be used for axis annotation relative to the current setting of "cex""
#' @param center If TRUE the labels will be drawn in the center beside the colors
#' @param labels If not NULL it overwrites the default labels given by levels in x.list
#' @param border Colour of the border around the colour bar and the axis (but not ticks)
#' @param triangle_ends If not NULL it must be a logical vector with two elements. If an element is TRUE a triangle is plottet instead of a rectangle at the end of the color bar. First element gives the values for the start of the colour bar, the second element for the end of the colour bar
#'
#' @return Nothing to return
#'
#' @details There must be one more levels than colours including the colour for water (\code{sea.col}).
#' The enumeration of side is consistent with \code{axis()}, e.g. from 1 to 4 clockwise from bottom.
#' Only every nn'th label is drawn.
#' Ticks are omitted if centered labels are drawn.
#'
#' @author Jonas Bhend, Burkhardt Rockel (HZG)
#'
#' @seealso \code{\link{plotmap}}
#'
#' @examples
#' tmp <- plotmap(file, ...)
#' plot_colourbar(tmp, triangle_ends=c(TRUE,FALSE),border=NA)
#'
#' @export
`plot_colourbar` <-
function (x, ...){
UseMethod("plot_colourbar")
}
#' @describeIn plot_colourbar Default, plots a colour bar given the levs and cols
`plot_colourbar.default` <-
function(levs, cols, side=1, ylab="", labels=NULL,
xlab="", nn=1, center=F, cex.axis=1, sea.col=NULL, sea.lab=NULL, border=par("fg"), triangle_ends=NULL, ...){
......@@ -184,6 +217,7 @@ function(levs, cols, side=1, ylab="", labels=NULL,
}
#' @describeIn plot_colourbar Color bar for plotmap
`plot_colourbar.plotmap` <-
function(x, incl.units=T, side=1, cex.axis=1, labels=NULL, center=F, ...){
if (!is.null(x$flag_values)){
......
This diff is collapsed.
#' Create a mask from a given closed polygon
#'
#' This function reads a closed polygon given as geographical longitude and latitude pairs.
#' The inner part of the polygon is given the value 1. The value in the outer part can be chosen by the user. This value will be interpreted as undefined in netCDF.
#' Optionally the created mask can be written into a file
#'
#' @param Cfile NetCDF input file containing the information of the domain
#' @param Pfile ASCII input file containing the polygon points in geographical coordinates. One longitude latitude pair per line.
#' @param Mfile Output file receiving the mask
#' @param multiply allows for fractional grid box values in the vicinity of the polygon line. \code{multiply} is the factor by which the grid is inflated temporarily during the computation. 1 = no fraction, 2 = halfs, 3 = thirds, 4 = quarters, etc.
#' @param skiplines lines to be skipped when reading from Pfile
#' @param undef value in the outer part of the polygon
#'
#' @return Returns a matrix of dimension nlon x nlat of fractional gridbox area within the polygon.
#'
#' @note Multiple polygons in a file must be divided by lines holding "-999 -999"
#'
#' @author Burkhardt Rockel (HZG)
#'
#' @examples
#' # create a mask with fractional grid box coverage and skip the first line when reading the polygon file
#' polymask (Cfile="/path/lffd2001010100.nc", Pfile="/path/polygon.txt", Mfile="/path/mask.nc", multiply=4, skiplines=1)
#'
#' @export
polymask<-function(Cfile, Pfile, Mfile=NULL, multiply=1, skiplines=0, undef=-1.E20, ...) {
#
......
#' Set the position of a mini-plot within the active plot region and reset to mother plot
#'
#' Sets the position of a mini plot within the active plot region at user coordinates x and y.
#'
#' @param x x coordinate value of center of mini plot
#' @param y y coordinate value of center of mini plot
#' @param size size relative to the existing plot
#' @param bg Background colour for the new plot
#'
#' @details The size can be given either as a single value
#' or a pair for centered mini plots, or as a vector
#' of length 4 for arbitrary positioned plots. The
#' sequence of the arguments is c(xleft, xright,
#' ybottom, ytop) (e.g. size = c(0,0.2,0,0.2) positions
#' the plot to the upper right of the indicated position).
#'
#' \code{set_position} writes a hidden variable named \code{.par_old}
#' to the parent environment, which is subsequently used by
#' \code{reset_position}.
#'
#' @author Jonas Bhend
#'
#' @seealso \code{\link{par}}, \code{\link{map}}
#'
#' @examples
#' # add random numbers in Northern Germany
#' map(xlim=c(-15,35), ylim=c(35,75))
#' set_position(10,55,0.2,bg="white")
#' plot(rnorm(50), pch=".", xaxt="n", yaxt="n", xlab="", ylab="")
#' reset_position()
#'
#' @export
`set_position` <- function(x, y, size=0.1, bg=NULL){
# sets the display for a plot centered at x,y
.old_par <<- par(no.readonly=TRUE)
......@@ -30,6 +63,7 @@
}