Making 2D plots with blender

Octavio Gonzalez-Lugo
2 min readApr 15, 2020

--

In this post, I will show you how to create a 2d data visualizations with blender.

Before making any mesh manipulation we load the data to be plotted, in this example, I’m going to use a continuous function. With that function, we create a mesh grid element with NumPy, with the same number of subdivisions in the grid. Then we obtain the displacement values by applying the function to the mesh and scale the displacement to [0,1]. Those scaled values will be used to create the plot.

Know that we have the mesh, we create a new bmesh element that will be used for the mesh manipulation. From that mesh element, we select all the faces and calculate the displacement normal to the face. Then we add that displacement to each vertex in the face and send all the mesh manipulations to the mesh object.

With the surface in place, we can add a color map relative to the displacement. First, we create a range n of evenly spaced colors in the RGB color space and n+1 evenly spaced values between [0,1] with.

Then we add n new materials to the mesh material list. We take the center value and use it to determinate the material, using the evenly spaced values as boundaries.

Finally, we add the axes to the plot and we obtain.

Know that we have a quick way to create a 2D plot and add a color map to it. As well as how to manipulate mesh objects with blender.

In four medium posts, I just exemplify how to make some of the most common data visualizations. The bar plot, the scatter plot, graphs or networks, 2D plots and color maps. Although there are some other more specialized visualizations, those are extensions of the basics, a histogram can be a series of bar plots, a line plot can be a scatter plot with its points joined together, a choropleth map can be a color map with a different mesh.

On the next posts, I will show to create dashboards as well as how to include new sources of data to blender. As always the complete code for this tutorial can be found at my GitHub by clicking here. See you in the next one.

--

--

Octavio Gonzalez-Lugo
Octavio Gonzalez-Lugo

Written by Octavio Gonzalez-Lugo

Writing about math, natural sciences, academia and any other thing that I can think about.

No responses yet