Skip to content

Latest commit

History

History
73 lines (52 loc) 路 2.09 KB

File metadata and controls

73 lines (52 loc) 路 2.09 KB
authors
Dominique Makowski
categories
Python
NeuroKit
date 2020-05-16T00:00:00Z
draft false
featured false
image
caption placement
A Mandelbrot fractal made with Python using NeuroKit
0
subtitle Create a Mandelbrot or Buddhabrot fractal in Python using NeuroKit.
summary Create a Mandelbrot or Buddhabrot fractal in Python using NeuroKit.
tags
Python
Fractal
Mandelbrot
Buddhabrot
NeuroKit
title One Python code line for a Mandelbrot fractal

Mandelbrot Set

I wrote a small Python function to easily generate and plot a Mandelbrot set. This function is now available through the NeuroKit2 package, and can be used as follows:

import neurokit2 as nk

nk.fractal_mandelbrot(show=True)

The Mandelbrot set is defined in the between -2 and 2 on the x (real) and y (imaginary) axes. Following that, the image can be cropped accodingly by changing the coordinates. Moreover, the colors can be tweaked by changing the the colormap (cmap).

m = nk.fractal_mandelbrot(real_range=(-2, 0.75), imaginary_range=(-1.25, 1.25))
plt.imshow(m.T, cmap="viridis")
plt.axis("off")
plt.show()

Buddhabrot Set

It is also possible to generate a Buddhabrot:

b = nk.fractal_mandelbrot(size=1500,
                          real_range=(-2, 0.75), imaginary_range=(-1.25, 1.25),
                          buddha=True, iterations=200)
plt.imshow(b.T, cmap="gray")
plt.axis("off")
plt.show()

{{< x user="Dom_Makowski" id="1258376273451053056" >}}

Althoug the NeuroKit Python package is primarily devoted at physiological signal processing, in also includes tons of other useful features.

馃憠 Discover more about NeuroKit here 馃憟

Have fun!


Thanks for reading! Do not hesitate to tweet and share this post, and leave a comment below 馃

馃惁 Don't forget to join me on X @Dom_Makowski