/python_3D_visualization_p3vi

A hackable, step-by-step for visualizing a 3D graph Python-object

Primary LanguageJupyter NotebookGNU General Public License v3.0GPL-3.0

Python 3D Visualization (p3vi) project

Welcome to the "Python 3D Visualization" (p3vi) project. Similarly to the "Python 2D Graph" (p2go) project, it is a hackable, step-by-step for visualizing a 3D graph Python-object.

I classify the "p3vi" as a "sandbox" or "toy" project. In other words, it is a fun, experimental project focusing on solving one problem.

We learned using graph-paper to draw linear algebra equations in Jr. High school, and to some extent, a 3D graph of cubes and cones. In math, we learned to work with 3, 4, n-th dimensions arrays. Therefore, I thought I have adequate working knowledge of spatial acuity.

But I was wrong. Tracing an arbitrary line in a 3D graph, using the "x, y and z" coordinate, is not simple. It is not simple for me. There are plenty of Python libraries that draw commonly used 3D charts to visualize extensive data set, such as terrain graph or weather formation. Still, none enable me to draw an arbitrary 3D line, not from the linear equation, or visualize my far-fetched ideas of graphing NLP data in 3D or finding 3D-patterns in image categorization.

As with the "p2go" project, why not do it yourself? I earnestly believe in strengthen original-thinking over memorizing terminology. It is wise to learn from others, but why stop there? Your wild hunches are as significant as the great discoveries in their early stage.

So if you are ready, let's take a collective calming breath … … and begin.

2 - The Journey

  • As a good little programmer, we start by creating an object or class.

  • When importing "numpy" and "matplotlib," my programing style is NOT using the global-space as in "import numpy *" NOR using the shorten name like "import matplotlibl.pyplot as ptl." I am NOT using Python's syntax shortcut because I'm switching between Python, Javascripts, and Swift.

  • I use a notebook to interactively writing the code, and afterward, I copy the code into a Python project using Atom IDE. https://atom.io/

The journey continues in the Jupyter notebook.

  • https://github.com/duchaba/python_3D_visualization_p3vi/blob/master/Python_3D_Graphs_p3vi.ipynb

  • Sample output-graphs from the notebook are as follows.

  • It is a long journey with our trusting friend, "Ducky," the dog. We start with an "x,y, and z" coordinate 3D-data set, and draw lines in 3D space.

  • I found that I need to improve my 3D spatial acuity, so we teach Ducky about drawing a box as a frame, draw points with the lines, label the axis, and mark each point with a sequence number.

  • We are not satisfied to stop where other books, blogs are classes end. We tilt and rotate until we satisfied that we fully grasp the 3D spatial acuity.

  • Along the way, Ducky and I encourage you to hack this Jupyter notebook. It is because having one original thought is equal to one thousand terminologies that you memorized.

  • Pushing forward in our journey, we deep dive into 2.5D bar charts and 3D bar charts. We found that understand the "x,y, and z" coordinate 3D-data set is paramount. Coding the 3D graphs are easy after we know how to create the 3D-data matrix.

  • Looking for a more useful 3D-data set than random coordinates, we detour to the parametric math equations. As it turns out, parametric equations create beautiful 3D surface maps.

  • I am happy that we traveled together, but I would be ecstatic if you have hacked the notebook and make it your journey. I hope to see you on our next adventure.

The End.

3 - Conclusion

It is one of the best journeys that I wrote. I learn more about the 3D graph then the past four years of using 3D plot packages, libraries, and stand-alone programs, both open-source and paid versions.

I previewed this Jupyter notebook to a handful of friends, and they hacked it. They took the "p3vi" object down the rabbit-hole of their discipline. I'm pleading with them to publish their finding on a Jupyter notebook and not to their professional or trade blog sites.

Teaching is about fostering original thoughts and not about memorization. Once I start doing it with a Jupyter notebook, there is no going back. The notebook gives us interactivity and individuality. No book, audio, or video can do that. It makes no difference that I am teaching myself or teaching others.

The next time you or I re-read the notebook, we can hack it and make it into something new. The notebook enables you to explore a brilliant epiphany or silly hunches.

For example, I took the simple "spring" parametric equation above and plotted it using a surface map. The results are more on the silly hunches side, but they are beautiful. It's such a price for exploration. It's 98% dead-ends, scraped knees, and bloody noses.

output

Beyond the power of sharing and interactivity, the notebook is a more efficient method for trying out new coding concepts before using an IDE, like Atom, to program it.

I wish that I know about using Jupyter notebook five, ten years ago. Back then, I was working for LeVar Burton to create interactive mobile book apps. Can Jupyter's notebook extend beyond computer and math to art, music, and storytelling? I don't know, but I would love to find out.

Samples images from the notebook.

output

output

output

output

output