Newly tracked file
R/visualize_phyloregions.R
changed.
Other files ignored by Codecov
man/plot.phyloregion.Rd
has changed.
35 | 35 | #' scaling color space matching the color vision of the human visual |
|
36 | 36 | #' system. The name is matched to the list of available color palettes from |
|
37 | 37 | #' the \code{hcl.colors} function in the \code{grDevices} package. |
|
38 | + | #' @param col vector of colors of length equal to the number of phyloregions. |
|
38 | 39 | #' @param shp a polygon shapefile of grid cells. |
|
39 | 40 | #' @param \dots arguments passed among methods. |
|
40 | 41 | #' @return No return value, called for plotting. |
45 | 46 | #' @importFrom graphics plot plot.default |
|
46 | 47 | #' @rawNamespace export(plot.phyloregion) |
|
47 | 48 | #' @export |
|
48 | - | plot.phyloregion <- function(x, shp=NULL, palette="NMDS", ...) { |
|
49 | + | plot.phyloregion <- function(x, shp=NULL, palette="NMDS", col=NULL, ...) { |
|
49 | 50 | if (!inherits(x, "phyloregion")) |
|
50 | 51 | stop("object \"x\" is not of class \"phyloregion\"") |
|
51 | 52 | if(is.null(shp)) shp <- x$shp |
|
52 | 53 | if(is.null(shp)) stop("Need shape file!") |
|
53 | 54 | k <- x$k |
|
54 | - | if(palette=="NMDS") clr <- shp$COLOURS |
|
55 | - | else clr <- hcl.colors(k, palette)[shp$cluster] |
|
56 | - | plot(shp, col = clr, ...) |
|
55 | + | #l <- length(shp$cluster) |
|
56 | + | if(is.null(col)){ |
|
57 | + | if(palette=="NMDS") col <- shp$COLOURS |
|
58 | + | else col <- hcl.colors(k, palette)[shp$cluster] |
|
59 | + | } |
|
60 | + | else{ |
|
61 | + | if(length(col)==k) col <- col[shp$cluster] |
|
62 | + | else stop("Expect 'col' of length x$k!") |
|
63 | + | } |
|
64 | + | plot(shp, col = col, ...) |
|
57 | 65 | text(shp, labels = as.character(shp@data$cluster), ...) |
|
58 | 66 | } |
|
59 | 67 |
Files | Coverage |
---|---|
R | 7.87% |
Project Totals (37 files) | 7.87% |