# How to plot the Mandelbrot set

## Adding colors to the Mandelbrot Set

In order to add some colors, one could associate a color for each possible value of iterations.

In the following example, we are switching from RGB colors to HSV (hue, saturation, value) colors. This allows us to change the color easily by modifying only the hue.

### Smooth coloring

In the previous example, you can see bands of color. To remove these bands, we can use a fractional escape count, also known as "normalized iteration count". The theory is a bit difficult, if you are interested in the mathematics, you should read this article entitled "Renormalizing the Mandelbrot Escape".

The `mandelbrot`

function must be modified to add to the result `1 - log(log2(abs(z)))`

where `z`

is the last computed value of the sequence (`abs(z) > 2`

).

You can also increase the value of `MAX_ITER`

to improve the rendering.

### Histogram coloring

In the previous codes, the colors are not equaly distributed. That's particularly true when `MAX_ITER`

is high. To improve the situation, the number of pixels for each iteration number is counted up. For each iteration number, a color will be associated by giving a wider range of colors for iteration numbers that concerns more pixels.

And that's all for the Mandelbrot Set! And if you like the Mandelbrot Set, you'll love the Julia Sets!