# Custom coloring function?

**URL:** <https://discourse.julialang.org/t/custom-coloring-function/67417>\
**Category:** General Usage\
**Tags:** question, plotting, plots\
**Created:** [August 31, 2021, 10:40am UTC](https://discourse.julialang.org/t/custom-coloring-function/67417 "2021-08-31T10:40:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [August 31, 2021, 10:40am UTC](https://discourse.julialang.org/t/custom-coloring-function/67417/1 "2021-08-31T10:40:21Z")

</div>

Hi!

I’m trying to plot a function `f` returning complex values using `contour`. `f` has a limited number of possibly returned values, which I’d like to plot with a unique color in the resulting contour plot. I thought I could maybe give `Plots` a custom function returning a color for each possible value returned by `f`, but I can’t seem to find how to do this in the documentation. I don’t think I can use color series or palettes, as the values returned by `f` are not continous (but at least there is a finite number of them).

At the moment I’m just plotting the phase of the complex values instead of the values themselves, but even then I can’t find a palette that shows the distinction between the values in a good way.

Am I missing something or is this not possible? Maybe I need a custom plotting recipe?

I’m using `Plots`, currently with the GR backend but I don’t mind swapping it out.

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [August 31, 2021, 10:46am UTC](https://discourse.julialang.org/t/custom-coloring-function/67417/2 "2021-08-31T10:46:07Z")

</div>

The function returns values like these:

```julia
5-element Vector{ComplexF64}:
  0.0 + 0.0im                
  0.0 - 1.0im                
 -1.0 + 0.0im                
  1.0 + 0.0im                
  0.0 + 1.0im                

```

or these:

```julia
13-element Vector{ComplexF64}:
  0.0 + 0.0im                 
  0.0 - 1.0im                 
 -1.0 + 0.0im                 
  0.0 + 1.0im                 
  1.0 + 0.0im                 
  1.0 - 1.0im                 
 -1.0 + 1.0im                 
  0.0 + 7.0im                 
  0.0 + 6.0im                 
  0.0 + 5.0im                 
  0.0 + 4.0im                 
  0.0 + 3.0im                 
  0.0 + 2.0im                 

```
