The main objectives in producing `contoureR`

, is to make it very easy to contour non-regular data, and, to be able to render this data over a non-regular canvas. In principal it is quite easy to use, but before anything else, we need to install some pre-requisites:

Firstly, if it is not already installed, you will need to install `geometry`

, as this package provides some cornerstone methods to `contoureR`

:

1 2 |
#Install the geometry package if(!require('geometry')){ install.packages('geometry') } |

Secondly, I would also suggest to install the highly accomplished `ggplot2`

package, simply because it’s awesome:

1 2 |
#Install the ggplot2 package if(!require('ggplot2')){ install.packages('ggplot2') } |

If the above complete without error, let’s proceed to install the `contoureR`

package from repository:

1 2 |
#Install the contoureR package install.packages('contoureR') |

### Basic Usage

Now for the fun stuff, in the following snippet, lets contour a mathematical function, and restrict the contours over non-regular (circular) bounding region:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# Contour Lines for a Function, Constrained to a limited domain # An example of the provision of non-regular data library(contoureR) library(ggplot2) a = -2; b = +2; n = 150 x = runif(n*n,a,b) y = runif(n*n,a,b) df = data.frame(x,y) df$z = with(df,-x*y*exp(-x^2-y^2)) #Limit the Domain df.sub = subset(df,x^2 + y^2 < 2) #Execute the Contouring Routine df.cnt = getContourLines(df.sub,nlevels=20) #Now Plot the Data ggplot(data=df.cnt,aes(x,y,group=Group,colour=z)) + geom_path() + theme_bw() |