3D Infographics and Data visualization Tutorial
The functional art of datavisualization and infographics applied on the blender most used practices of python scripting and modelling. A collection of tutorials from around the web and a complete lesson.
I collected every method I had to use to get the good work I didn’t get finished in the end…
Some of this work are not online anymore, and I’m sure that the blender community will appreciate them to be republished in the same, accurate and detailed sequence.
Here you’ll find content about:
- bar charts
- maps with localized bar charts
- maps with bubble charts
This tutorial requires you to be aware of:
- basic modelling
- basic python scripting
- particle design
- UV mapping
I really don’t like video tutorials’ invasion of the web (maybe because of my problem of bandwich?) so I’ll try to keep this article readable as plaing text and images, the related video tutorials are listed inside the themed paragraph, but yur can read and understand this tuts by reading them.
This is not actually a tutorial, it’s a tip for creating 3D bar charts from a .csv file using automated python scripts in blender, it is updated for blender 2.6 scripting API and the creator of the script runs a blog on bzstat.wordpress.com.
This package contains the script, the blender file and a csv file you can simply edit with your favorite editor.
To get the chart run the barchart.py script (embedded in the barchart.blend file) from the command line (dos box).
"c:\Program Files\Blender Foundation\Blender\blender.exe" -b barchart.blend -P barchart.py -- data.csv
"c:\Program Files\Blender Foundation\Blender\blender.exe" -P barchart.py -- data.csv
"c:\Program Files\Blender Foundation\Blender\blender.exe" -b -P barchart.py -- data.csv
(No Blender to pop up.)
Of course your blender.exe might be in another location. The output of the script will be a
.png file with the same name (but different extension) as the .csv file specified. The .png
file will be created in the current working directory.
Maps, Geolocalized Bar Charts
This kind of charts require some modelling skills, but you can take advantage of these two maps already modelled covering USA and Europe, the tutorial covers the modelling part also, so is useful for very beginners and was written on www.blendercycles.com, I can’t find the owner of this domain that now is free but I saw it is linked on the main blender.org tutorial page, although it’s not working anymore, so here is a repost of this useful tutorial for beginners.
A lot of us have probably seen those maps in magazines and newspapers where they raise up states based on numbers assigned like population or home prices, etc. We are going to be using Blender to make one of those maps and make the states (or provinces) easy to scale.
While you should use Reference images for everything, you especially need one for this tutorial. Luckily, USA maps are as plentiful as sand on Google, so you should have no trouble finding one. Try to get one with clear state lines and is a proportional projection, not a flat projection. If you do not live in the USA (And from what Clicky Analytics has told me, almost two-thirds of you don’t), just find a provincial map of your own country. It doesn’t matter. Just get a map.
To model the states, add a plane, and in edit mode, move it over to a state or province.
(shortkeys: A to select all vertices and G to grab them)
Then delete three of the vertices with the “delete” key button, and move the remaining vertex to the border of a state with the G shortkey.
Start extruding using the E kay and moving new vertices with the G key or the manipulator tools.
Once you finish, close off the outline by selecting the two ends and hitting the F key to form an edge between them.
Select the outline with Ctrl-L key and use Alt-F key to fill the outline with faces. This is one of those rare times in 3d modeling where you don’t have to worry about topology since you only need to solidify and scale it.
Duplicate one of the vertices with shift-D key, grab it and start with the next state.
Repeat for the rest of the states.Once you finish, you can go back into object mode (menu on the bottom of the 3D viewer) and see the finished map.
However, it’s one huge chunk. Divide it into the individual states by going back into edit mode, selecting each state’s vertex together and pressing P.
Choose “By Loose Parts” from the menu, and the map will be split into pieces.
To join vertices on islands owned by the same state you have to press J key.
Unfortunately, all the states share the same rotation center.
Fix that by selecting everything, hitting the space bar, and typing in “Set Origin”. The option should come up, and choose “Origin to Geometry” from the menu.
As you can see, the states now have their own rotation centers.
Next, we have to solidify the states. Turns out you can skip a step and just go into the Text Editor and paste in:
#Iterate over all members inside the Object struct
for ob in bpy.data.objects:
#Check if object is a Mesh
if ob.type == ‘MESH’:
ob.modifiers[‘Solidifystates’].thickness = -0.5
Then hit “Run Script”.
And now, there’s thickness.
Buuuuttt…we have one more problem. Some of the islands are reversed!
You’re going to have to delete the bottom vertices and extrude them up to fix them. The Snap function is very useful for this.
And that takes care of everything. Since the origins are on the bottom of the states, when you scale them, they only scale upwards, and you can just type values into the Z-scale box (in the object panel on the properties window) to have it automatically raised.
If you want, you can assign colors to the states or provinces too, use the material panel for this operation.
-To reset the map, select everything and hit the Alt-S key
Animated Maps with Bubbles
This tutorial was published on blendersushi by Jimmy Gunawan and uses particle systems to create geolocalized bubbles on a map and animate it through UV mapping.
The tutorial is useful if you know these procedures, if you don’t, please take a look to the linked tutorials.
Here is the video with the final result:
And here is the video tutorial:
On first instance the data, data for infographics can vary per project. For this earthquake infographics we can see:
- Point Locations in Map
- Time span (a day)
- Magnitude of the earthquakes
Some data will be more detailed giving points in Lat/Long and time in Date/Time but this will not be our case.
And there is also the stage where we need to decide the right representation or design of the infographics.
But what we will be focusing on is the animation of circles shown on the video using Blender. This will not be a 100% complete solution, but you will learn few useful techniques. We will create a simple example where we will be manually placed the point.
Check NodeBox way to import point data into XY coordinate. You can definitely use that.
Now, with infographics like ours about the earthquake we have many options to animate the content, using size, transparency and text Value Animation.
We can also add an extra attribute to animate: Color. You see how each Particle has some kind of special radius to represent the magnitude? We could also deal with that.
But for simplicity sake, we will just animate the Circle Size in this tutorial.
Doing it manually… sounds like a lot of work, right? It does, but it is good to know and then figure out a more automatic or procedural way to animate this.
For this example, we will just use 7 Circles, with Spectrum Color so that it is obvious what happening. We will place this Circles at random location on map of Australia from Google Map:
The steps for this process is as you think how it is:
- Animate one of the circle, perhaps the red color. Animate the scale for now.
- Next, you “copy” the animation into other shape.
How? You go to Action Editor inside Dopesheet and apply the same action you did to original circle to all other circles. You can then offset the animation for each one of the circle to make sure the timing is correct.
This method won’t be the one explained in our tutorial.
Let’s take a look at next method.
We will be using Particles to animate our Circle appear, grow in scale, and then disappear. What interesting is the fact that Particles in Blender is really practical for this matter. Particle can be set to be born following vertices order (if sorted correctly) of mesh, and even better Particle Instance Group is also sortable.
This is step by step how:
- First of all, we know there are 7 circles, so we will create a mesh object with 7 vertices to emit 7 Particles, in which in fact it should emit the 7 rainbow colored circles in order. That mesh object will also represent the point location of our circles.
- Group our 7 Circles, this will be applied as Group Instance
- Emit Particles from our mesh edge, adjust settings like below:
Most important here is to adjust the Start and End, and Lifetime (of each Circle), this will result in the proper timing of circles to appear.
Ok, now if you notice, the circles will just pop up. We do not want that. We want each circles emitted by Particle to appear slowly and disappear slowly. How do we control this? Particle Texture is the answer:
Now you have the animation of circles growing and disappearing. You can adjust the timing again using Start-End and Lifetime value. And also the Particle Texture Ramp.
CONTROLLED VS RANDOM CIRCLE SIZES
At this moment, you may notice that all our circles are the same in size? It does not have any variations. How do we add variations based on specified value? By using Vertex Weight.
For each vertex mesh that is emitting particle, or circle in this case, we will apply different vertex weight. Perhaps for this 7 circles, it represent different magnitude of earthquake, so we will do exactly that but normalized. For vertex weight, we apply value between 0-1.
Anyhow, if you apply vertex weight into mesh vertices, this will result in circles with size variations that is controlled.
If you want just RANDOM value, you can easily do this by quickly changing the Particle setting. But for this, we do not want random, we actually want the exact circle size.
Applying Vertex Weight into the mesh will not take any effect, until you actually activate Blender Particle Hair and tell it to use the Vertex Weight under Length slot.
The funny thing at this state is that we lost our Particle growing animation. The only way we can get this back is by using Dynamic Paint.
CIRCLE ANIMATIONS – DYNAMIC PAINT WAY
Dynamic Paint will be the last step in this setup. It allows us to have manual control over the size of circles.
Set Mesh Edge as Canvas and another object as Brush to control the animation.
You need to use Vertex Weight Mix Modifier to combine Vertex Weight created by Dynamic Paint in realtime with Vertex Weight that we have applied manually.
If you did everything correctly, we have now completed setup for Earthquake Infographics Animation.
To add more complicated effect like changing color or instance by Particle Color Ramp, you need extra add-on like RE:Ticular by ATOM. Or, you use that other conceptual technique I did using Drivers and Dynamic Paint to control everything. It’s fairly complex, but do-able.