---
title: "Create Matplotlib Compatible Color Map"
---

### Description

Converts the current palette into a
`matplotlib.colors.LinearSegmentedColormap` color map based on the
colors provided creating this palette object. If `continuous = True`
a series of `256` unique colors will be created using linear
interpolation in the standard RGB color space. If `continuous = False`
the resulting color map is solely based on the number of colors of
the palette which yields a non-continuous color map with step-functions
in R, G, and B (see Example).

### Usage

<pre><code class='language-python'>palette.cmap(continuous=True)</code></pre>

### Arguments

<dl class="pyp-list param-list">
  <dt style = "white-space: nowrap; font-family: monospace; vertical-align: top">
   <code id="colorspace.palettes.palette.cmap:continuous">continuous</code><code class="argument-class">bool</code>
  </dt>
 <dd>If `True` (default) the resulting colormap
will contain 256 colors, linearely interpolated in between
the colors of the palette. If `False`, only the `N` colors
of the palette are used (see Examples).</dd>
</dl>

### Examples

```{python}
#| echo: true
#| warning: true
#| error: true
from colorspace import diverging_hcl, palette, specplot
pal = diverging_hcl()
pal = palette(pal(5), name = "Diverging Palette with 5 Colors")
# Continuous colormap
cmap1 = pal.cmap(continuous = True)
cmap1.N # Internal number of colors
```

```{python}
#| echo: true
#| warning: true
#| error: true
# Non-continuous version of the colormap
cmap2 = pal.cmap(continuous = False)
cmap2.N # Internal number of colors
```

```{python}
#| echo: true
#| warning: true
#| error: true
# Using helper function for demonstration
specplot(cmap1, rgb = True, figsize = (8, 6));
```

```{python}
#| echo: true
#| warning: true
#| error: true
specplot(cmap2, rgb = True, figsize = (8, 6));
```




### Raises

<ul class="python-raises">
<li><code class="text-warning">TypeError</code>: If `continuous` is not bool
</ul>

