# Making Custom Colormap with Makie

**URL:** <https://discourse.julialang.org/t/making-custom-colormap-with-makie/110965>\
**Category:** Visualization\
**Tags:** makie, cairomakie\
**Created:** [February 29, 2024, 4:40pm UTC](https://discourse.julialang.org/t/making-custom-colormap-with-makie/110965 "2024-02-29T16:40:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Post date:** [February 29, 2024, 4:40pm UTC](https://discourse.julialang.org/t/making-custom-colormap-with-makie/110965/1 "2024-02-29T16:40:00Z")

</div>

Hello,

I’m wondering what is the best way to implement my own custom colormap for use in Makie. I am using CairoMakie to generate plots and I want to be able to specify a colormap and then generate smaller maps from those for the purposes of coloring line plots. For example, there is a colormap called `:Dark2_8`. I can generate a subset of colors for plotting from that by doing `resample_cmap(:Dark2_8, 6)` (if I have 6 lines in my plot for example).

Currently I have my custom map implemented like this.

```julia
mymap = [...] # Vector of 20 colors defined as a vector of RGBf()

```

Then I create the smaller lists of colors for line plots by doing

```julia
mymap4 = resample_cmap(mymap, 4)

```

This appears to work.

But I’m wondering if there is the best way. For example, how could I implement it so that it behaves like `:Dark2_8` so that I could call `mymap4 = resample_cmap(:mymap, 4)`.

I tried the following (based on the source [here](https://github.com/JuliaGraphics/ColorSchemes.jl/blob/master/src/ColorSchemes.jl)).

```julia
Makie.loadcolorscheme(
    :mymap,
    mymap
)

```

But I get the following error when I try to do `resample_cmap(:mymap, 4)`

```julia
ERROR: There is no color gradient named mymap.
See `Makie.available_gradients()` for the list of available gradients,
or look at http://docs.makie.org/dev/generated/colors#Colormap-reference.

```
