Skip to content
Snippets Groups Projects
Commit 942599d0 authored by thierrychambert's avatar thierrychambert
Browse files

Added manual for custom_palette

+ some minor eolpop-package cleaning
parent f87533e7
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ export(M3_WithDD_noDemoStoch)
export(M4_WithDD_WithDemoStoch)
export(build_Leslie)
export(calibrate_params)
export(custom_palette_c25)
export(elicitation)
export(get_metrics)
export(infer_DD)
......
......@@ -23,3 +23,33 @@ custom_palette_c25 <- function(){
)
}
##==============================================================================
## Function to control color transparency ==
##==============================================================================
#' Function to control color transparency on a plot
#'
#' @param someColor some color name, such as "green", "red", etc.
#' @param percent the desired % of transparency, between 0 (no transparency) and 100 (full transparency) .
#'
#' @return a Hex Code including the desired transparency level, such as #RRGGBB7F
#' @export
#'
#' @import RColorBrewer
#' @import grDevices
#'
#' @examples
#' make_transparent("green", percent=50)
make_transparent <- function(someColor, percent=100)
{
newColor <- col2rgb(someColor)
apply(newColor, 2,
function(curcoldata){
rgb(red = curcoldata[1], green = curcoldata[2], blue = curcoldata[3],
alpha = (100 - percent) * 255 / 100, maxColorValue = 255)
}
)
} # End function
################################################################################
......@@ -55,7 +55,7 @@ plot_traj <- function(N, onset_year = NULL, xlab = "Year", ylab = "Population si
# change color palette (we want sc0 in black)
p <- p +
scale_color_manual(breaks = 1:nsc,
values = palette()[1:nsc],
values = palette.colors(n = 9*10, recycle = TRUE)[1:nsc],
labels = Legend, aesthetics = c("colour", "fill"))
......@@ -92,33 +92,3 @@ plot_traj <- function(N, onset_year = NULL, xlab = "Year", ylab = "Population si
} # End function
################################################################################
##==============================================================================
## Function to control color transparency ==
##==============================================================================
#' Function to control color transparency on a plot
#'
#' @param someColor some color name, such as "green", "red", etc.
#' @param percent the desired % of transparency, between 0 (no transparency) and 100 (full transparency) .
#'
#' @return a Hex Code including the desired transparency level, such as #RRGGBB7F
#' @export
#'
#' @import RColorBrewer
#' @import grDevices
#'
#' @examples
#' make_transparent("green", percent=50)
make_transparent <- function(someColor, percent=100)
{
newColor <- col2rgb(someColor)
apply(newColor, 2,
function(curcoldata){
rgb(red = curcoldata[1], green = curcoldata[2], blue = curcoldata[3],
alpha = (100 - percent) * 255 / 100, maxColorValue = 255)
}
)
} # End function
################################################################################
......@@ -53,8 +53,7 @@ rMAX_spp <- function(surv, afr){
#' Johnson, F. A., M. A. H. Walters, and G. S. Boomer. 2012. Allowable levels of take for the trade in
#' Nearctic songbirds. Ecological Applications 22:1114-1130.
#'
#' @param surv Adult survival. Single value between 0 and 1.
#' @param afr Age at first reproduction. Single integer value.
#' @param rMAX_species Species rMAX value (Between 0 and +Inf)
#'
#' @return the theoretical Rmax of the species
#' @export
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/custom_palette.R
\name{custom_palette_c25}
\alias{custom_palette_c25}
\title{Custom color palette: 25 distinct colors}
\usage{
custom_palette_c25()
}
\value{
a vector of 25 color names
}
\description{
Custom color palette: 25 distinct colors
}
\examples{
custom_palette_c25()
}
......@@ -7,9 +7,7 @@
theta_spp(rMAX_species)
}
\arguments{
\item{surv}{Adult survival. Single value between 0 and 1.}
\item{afr}{Age at first reproduction. Single integer value.}
\item{rMAX_species}{Species rMAX value (Between 0 and +Inf)}
}
\value{
the theoretical Rmax of the species
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment