---
title: "Get Colors"
---

### Description

Returns the colors of the current color palette.

### Usage

<pre><code class='language-python'>rainbow.colors(n=11, alpha=None, **kwargs)</code></pre>

### Arguments

<dl class="pyp-list param-list">
  <dt style = "white-space: nowrap; font-family: monospace; vertical-align: top">
   <code id="colorspace.palettes.rainbow.colors:n">n</code><code class="argument-class">int</code>
  </dt>
 <dd>Number of colors which should be returned. Defaults to `11`.</dd>
  <dt style = "white-space: nowrap; font-family: monospace; vertical-align: top">
   <code id="colorspace.palettes.rainbow.colors:alpha">alpha</code><code class="argument-class">None, float, list, or numpy.ndarray</code>
  </dt>
 <dd>Allows to add an transparency
(alpha channel) to the colors. Can be a single float, a list, or a
numpy array. If a list or array is provided it must be of length 1 or
of length `n` and be convertible to float, providing values
between `0.0` (full opacity) and `1.0` (full transparency)</dd>
  <dt style = "white-space: nowrap; font-family: monospace; vertical-align: top">
   <code id="colorspace.palettes.rainbow.colors:**kwargs">**kwargs</code>
  </dt>
 <dd>Currently allows for `rev = True` to reverse the colors.</dd>
</dl>

### Return

<code>list</code>: Returns a list of str with `n` colors from the
color palette.

### Examples

```{python}
#| echo: true
#| warning: true
#| error: true
from colorspace import rainbow
rainbow().colors(4)
```




### Raises

<ul class="python-raises">
<li><code class="text-warning">ValueError</code>: If input `n` is not float/int or smaller than 1.
</ul>

