# Cycling categorical color scale for unlimited unique values in Makie?

**URL:** <https://discourse.julialang.org/t/cycling-categorical-color-scale-for-unlimited-unique-values-in-makie/129578>\
**Category:** General Usage\
**Tags:** visualization, makie, color-scale\
**Created:** [June 2, 2025, 7:07pm UTC](https://discourse.julialang.org/t/cycling-categorical-color-scale-for-unlimited-unique-values-in-makie/129578 "2025-06-02T19:07:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![oscarvdvelde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscarvdvelde/32/202157_2.png) [@oscarvdvelde](https://discourse.julialang.org/u/oscarvdvelde)\
**Post date:** [June 2, 2025, 7:07pm UTC](https://discourse.julialang.org/t/cycling-categorical-color-scale-for-unlimited-unique-values-in-makie/129578/1 "2025-06-02T19:07:32Z")

</div>

I am looking for a solution for a color map in Makie, for groups of points that need to be colored by their integer values (e.g. group number). There may be hundreds of unique values, so one can not see any visual difference between adjacent values when stretching a color map from its minimum to its maximum.

For each unique value, there should be a new color with sufficient visual difference, like is achieved with `cgrad(:Set1_6, 25; categorical=true)`. The number of unique values varies, so it is best that it automatically recycles the color map as many times as needed.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [June 3, 2025, 6:47am UTC](https://discourse.julialang.org/t/cycling-categorical-color-scale-for-unlimited-unique-values-in-makie/129578/2 "2025-06-03T06:47:24Z")

</div>

> [@oscarvdvelde](#):
>
> There may be hundreds of unique values, so one can not see any visual difference between adjacent values when stretching a color map from its minimum to its maximum.

You will not solve this by generating hundreds of distinct categorical colors. While you might be able to discriminate between pairs of colors with such small distances when they are next to each other, you’ll not be able to see which color is which if there are many small points in no particular order and you have to map this back to a legend.

You can try `Colors.distinguishable_colors` with high N but I think you have to rethink the approach anyway [Colormaps and Colorscales · Colors](https://juliagraphics.github.io/Colors.jl/stable/colormapsandcolorscales/#Generating-distinguishable-colors)

---

<div class="post-metadata">

**Author:** ![oscarvdvelde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscarvdvelde/32/202157_2.png) [@oscarvdvelde](https://discourse.julialang.org/u/oscarvdvelde)\
**Post date:** [June 5, 2025, 12:07pm UTC](https://discourse.julialang.org/t/cycling-categorical-color-scale-for-unlimited-unique-values-in-makie/129578/3 "2025-06-05T12:07:58Z")

</div>

Thanks for directing me to `Colors.distinguishable_colors`, Jules. Sounds good in itself, although in my Makie dashboard am changing the color map using an observable that contains the colorscale `Symbol` e.g. `:turbo`, so I need to find a way of producing my own `Symbol` color map from `Colors.distinguishable_colors` and the number of unique values, if that is possible.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [June 5, 2025, 1:54pm UTC](https://discourse.julialang.org/t/cycling-categorical-color-scale-for-unlimited-unique-values-in-makie/129578/4 "2025-06-05T13:54:37Z")

</div>

A colormap can also just be a list of colors, make an `Observable{Any}` if you can’t update because you’re constrained to `Symbol`

---

<div class="post-metadata">

**Author:** ![oscarvdvelde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscarvdvelde/32/202157_2.png) [@oscarvdvelde](https://discourse.julialang.org/u/oscarvdvelde)\
**Post date:** [June 7, 2025, 12:29pm UTC](https://discourse.julialang.org/t/cycling-categorical-color-scale-for-unlimited-unique-values-in-makie/129578/5 "2025-06-07T12:29:27Z")

</div>

> [@jules](#):
>
> You can try `Colors.distinguishable_colors` with high N

This indeed works for me, with the `Observable{Any}( )`. I set it, for example to 50 colors. This results in unique colors whenever I use up to that amount of unique integer values. For float values and greater numbers of unique integers, it interpolates between the colors, which is totally fine, as I would not try to distinguish values until I zoom in to a limited selection of data.
