smoothcontour {cooltools} | R Documentation |

## Draw smoothed contours

### Description

Draw smoothed iso-countours for a density field. The contours are computed using the `contourLines`

routine and smoothed using the `smooth.spline`

function. Both open and closed contour lines are handled correctly.

### Usage

```
smoothcontour(
x = seq(0, 1, length.out = nrow(z)),
y = seq(0, 1, length.out = ncol(z)),
z,
levels,
smoothing = 0.5,
min.radius = 1,
lwd = 1,
lty = 1,
col = "black",
...
)
```

### Arguments

`x` , `y` |
vectors containing the locations of grid lines at which the values of z are measured. These must be in ascending order. By default, equally spaced values from 0 to 1 are used. |

`z` |
matrix representing the density field on which the contours are plotted. |

`levels` |
vector of the iso-contour levels. |

`smoothing` |
value between 0 and 1 specifying the degree of smoothing. |

`min.radius` |
numerical value. If larger than 0, all contours with a mean radius (in pixels) below |

`lwd` |
vector of line widths (see |

`lty` |
vector of line types (see |

`col` |
vector of colors (see |

`...` |
additional parameters to be passed to the function |

### Value

None

### Author(s)

Danail Obreschkow

### See Also

### Examples

```
set.seed(1)
f = function(x) cos(2*x[1]-x[2]-1)^2*exp(-x[1]^2-x[2]^2-x[1]*x[2])
x = seq(-3,3,length=100)
m = pracma::meshgrid(x)
z = array(Vectorize(function(x,y) f(c(x,y)))(m$Y,m$X)+rnorm(4e4,sd=0.1),dim(m$X))
image(x,x,z,col=terrain.colors(100))
contour(x,x,z,levels=c(0.2,0.5),add=TRUE)
smoothcontour(x,x,z,levels=c(0.2,0.5),lwd=3,smoothing=0.8,min.radius=2)
```

*cooltools*version 2.4 Index]