EVOLUTION-MANAGER
Edit File: colorNumeric.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Color mapping</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for colorNumeric {leaflet}"><tr><td>colorNumeric {leaflet}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Color mapping</h2> <h3>Description</h3> <p>Conveniently maps data values (numeric or factor/character) to colors according to a given palette, which can be provided in a variety of formats. </p> <h3>Usage</h3> <pre> colorNumeric(palette, domain, na.color = "#808080", alpha = FALSE, reverse = FALSE) colorBin(palette, domain, bins = 7, pretty = TRUE, na.color = "#808080", alpha = FALSE, reverse = FALSE, right = FALSE) colorQuantile(palette, domain, n = 4, probs = seq(0, 1, length.out = n + 1), na.color = "#808080", alpha = FALSE, reverse = FALSE, right = FALSE) colorFactor(palette, domain, levels = NULL, ordered = FALSE, na.color = "#808080", alpha = FALSE, reverse = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>palette</code></td> <td> <p>The colors or color function that values will be mapped to</p> </td></tr> <tr valign="top"><td><code>domain</code></td> <td> <p>The possible values that can be mapped. </p> <p>For <code>colorNumeric</code> and <code>colorBin</code>, this can be a simple numeric range (e.g. <code>c(0, 100)</code>); <code>colorQuantile</code> needs representative numeric data; and <code>colorFactor</code> needs categorical data. </p> <p>If <code>NULL</code>, then whenever the resulting color function is called, the <code>x</code> value will represent the domain. This implies that if the function is invoked multiple times, the encoding between values and colors may not be consistent; if consistency is needed, you must provide a non-<code>NULL</code> domain.</p> </td></tr> <tr valign="top"><td><code>na.color</code></td> <td> <p>The color to return for <code>NA</code> values. Note that <code>na.color = NA</code> is valid.</p> </td></tr> <tr valign="top"><td><code>alpha</code></td> <td> <p>Whether alpha channels should be respected or ignored. If <code>TRUE</code> then colors without explicit alpha information will be treated as fully opaque.</p> </td></tr> <tr valign="top"><td><code>reverse</code></td> <td> <p>Whether the colors (or color function) in <code>palette</code> should be used in reverse order. For example, if the default order of a palette goes from blue to green, then <code>reverse = TRUE</code> will result in the colors going from green to blue.</p> </td></tr> <tr valign="top"><td><code>bins</code></td> <td> <p>Either a numeric vector of two or more unique cut points or a single number (greater than or equal to 2) giving the number of intervals into which the domain values are to be cut.</p> </td></tr> <tr valign="top"><td><code>pretty</code></td> <td> <p>Whether to use the function <code><a href="../../base/html/pretty.html">pretty</a>()</code> to generate the bins when the argument <code>bins</code> is a single number. When <code>pretty = TRUE</code>, the actual number of bins may not be the number of bins you specified. When <code>pretty = FALSE</code>, <code><a href="../../base/html/seq.html">seq</a>()</code> is used to generate the bins and the breaks may not be "pretty".</p> </td></tr> <tr valign="top"><td><code>right</code></td> <td> <p>parameter supplied to cut. See Details</p> </td></tr> <tr valign="top"><td><code>n</code></td> <td> <p>Number of equal-size quantiles desired. For more precise control, use the <code>probs</code> argument instead.</p> </td></tr> <tr valign="top"><td><code>probs</code></td> <td> <p>See <code><a href="../../stats/html/quantile.html">quantile</a></code>. If provided, the <code>n</code> argument is ignored.</p> </td></tr> <tr valign="top"><td><code>levels</code></td> <td> <p>An alternate way of specifying levels; if specified, domain is ignored</p> </td></tr> <tr valign="top"><td><code>ordered</code></td> <td> <p>If <code>TRUE</code> and <code>domain</code> needs to be coerced to a factor, treat it as already in the correct order</p> </td></tr> </table> <h3>Details</h3> <p><code>colorNumeric</code> is a simple linear mapping from continuous numeric data to an interpolated palette. </p> <p><code>colorBin</code> also maps continuous numeric data, but performs binning based on value (see the <code><a href="../../base/html/cut.html">cut</a></code> function). <code>colorBin</code> defaults for the <code><a href="../../base/html/cut.html">cut</a></code> function are <code>include.lowest = TRUE</code> and <code>right = FALSE</code>. </p> <p><code>colorQuantile</code> similarly bins numeric data, but via the <code><a href="../../stats/html/quantile.html">quantile</a></code> function. </p> <p><code>colorFactor</code> maps factors to colors. If the palette is discrete and has a different number of colors than the number of factors, interpolation is used. </p> <p>The <code>palette</code> argument can be any of the following: </p> <ol> <li><p>A character vector of RGB or named colors. Examples: <code>palette()</code>, <code>c("#000000", "#0000FF", "#FFFFFF")</code>, <code>topo.colors(10)</code> </p> </li> <li><p>The name of an RColorBrewer palette, e.g. <code>"BuPu"</code> or <code>"Greens"</code>. </p> </li> <li><p>The full name of a viridis palette: <code>"viridis"</code>, <code>"magma"</code>, <code>"inferno"</code>, or <code>"plasma"</code>. </p> </li> <li><p>A function that receives a single value between 0 and 1 and returns a color. Examples: <code>colorRamp(c("#000000", "#FFFFFF"), interpolate = "spline")</code>. </p> </li></ol> <h3>Value</h3> <p>A function that takes a single parameter <code>x</code>; when called with a vector of numbers (except for <code>colorFactor</code>, which expects factors/characters), #RRGGBB color strings are returned (unless <code>alpha = TRUE</code> in which case #RRGGBBAA may also be possible). </p> <h3>Examples</h3> <pre> pal <- colorBin("Greens", domain = 0:100) pal(runif(10, 60, 100)) # Exponential distribution, mapped continuously previewColors(colorNumeric("Blues", domain = NULL), sort(rexp(16))) # Exponential distribution, mapped by interval previewColors(colorBin("Blues", domain = NULL, bins = 4), sort(rexp(16))) # Exponential distribution, mapped by quantile previewColors(colorQuantile("Blues", domain = NULL), sort(rexp(16))) # Categorical data; by default, the values being colored span the gamut... previewColors(colorFactor("RdYlBu", domain = NULL), LETTERS[1:5]) # ...unless the data is a factor, without droplevels... previewColors(colorFactor("RdYlBu", domain = NULL), factor(LETTERS[1:5], levels = LETTERS)) # ...or the domain is stated explicitly. previewColors(colorFactor("RdYlBu", levels = LETTERS), LETTERS[1:5]) </pre> <hr /><div style="text-align: center;">[Package <em>leaflet</em> version 2.0.3 <a href="00Index.html">Index</a>]</div> </body></html>