Space-Filling Curves

In an effort to combine some of my new skills with my passion for mathematics, I recently wrote a bit of Python code that builds various space-filling curves by way of complex valued functions and plots them with matplotlib.  Furthermore I wanted to try some of the awesome online graphing tools provided through Plotly using their Python API. The visualizations on this posting are the results. 

What are space-filling curves?

In analytic geometry a curve is defined as a continuous map from a one dimensional space to an n-dimensional space. Intuitively, in 2-dimensions this is a line (not necessarily straight) that represents the graph of some "function" and it is how one defines this "function" that opens up a world of amazing objects.  One class of such objects is called space-filling curves which are curves whose range (outputs) contain the entire 2-dimensional unit square.  Most (not all) of these curves are constructed iteratively as the limit of a sequence of piecewise self-avoiding continuous lines, each become closer and closer to their space-filling limit. See the image below:

Visualizing the   iterative process of the curves become space-filling in their limit.

Visualizing the iterative process of the curves become space-filling in their limit.

The images above represent Hilbert's space-filling curve. The first visualisation at the beginning of this post is the Plotly graph I created by constructing the actual data points for each iteration of the first five curves using complex values and complex valued functions.  Then with Plotly's Python API I was able to further analyse the data and use some of their visualization tools for constructing the layered final image.

The beauty of these plots is the fact that all the data is actually plotted using complex values and representing the real and imaginary parts as (x,y) ordered pairs. This way I can manipulate the geometric aspects of complex analysis to creatively find other space-filling curves and fractal like visualizations. 

Furthermore, all Ploty graphs are embedded into this page so you can play around with the plots. Check the constructed values, zoom in and out on the graphs, and link to the actual spreadsheets of the data. Take a second and mess around with them. Zoom in to see the fractal like nature of these curves!!!

Feel free to check out the code here on github and my plots at Plotly here.