Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In the last several movies, we've introduced you to a number of ways to create graphics in Processing, both based on the formulas in your sketches and also based on references to external data. We've also shown you how to create the basic elements of interaction, by, for instance, being able to click on shapes and drag them, being able to roll over, have them change, respond, provide extra information, being able to slice through, being able to rotate, to zoom, to slide. These really are the basic forms of interaction for the great majority of data visualizations, and I think you'll find that as you take those elements, you'll be able to build almost everything that you want to do.
However, I did want to show you a few kinds of more elaborate data visualizations and user responsiveness that because they are rather lengthy, very time consuming, I wanted to show you the code from the built-in examples in Processing, really, so that you're aware that they exist, and you can take a look at them and see if they provide any kind of inspiration or direction for your own work. The three examples that I'm going to show you all come from one book by Ben Fry, one of the co-creators of Processing.
They are from his book Visualizing Data. It's an excellent resource, and I strongly encourage you to take a look at. It's relatively advanced, but it is very careful and steps through all the way. I want to show you three of the examples that come in the Processing example folder. So, for instance, if you have Processing open, you simply go to File, to Examples, and then this window here pops up, Standard Examples, and you go to Books, down to Visualizing Data.
And the two that I want to show you are first from the one that says ch03-usmap where he shows every step of a build of a map that has some data that's responsive on it. I wanted to show you number 16, step 16, very quickly. And what you have here--I'll pull that out--is that he's been taking step by step of getting a map of the United States and then superimposing what are actually random data points in the middle of each state, along with a rollover.
This is great work. This is where the Table class that we've been using comes from. And I want you to see some of the things that he is able to do to serve as an inspiration in your own work. I'm just going to hit Run here. And what we get is a map of the United States, with a dot in each central location. And there are two things that happen. Number one, if I press the space key, those dots change to other random values, where the colors indicate positive and negative and the size indicates the magnitude of the number. And they're totally random. These look like voting results, but they're just random numbers.
And what happens is first off, he has this nice little compression thing that refers to as the integrator, that makes it possible for these to change slowly from one to the other. The other one is if you hover over one of these, it actually gives you the name of the state and the current random number. Also, he's got a wonderful bit of code that makes it so that even when things are closed into each other, you don't accidentally queue the other state's information. Anyhow, this is a way of working with latitude and longitude, as well as data values, and providing levels of interactivity.
I suggest you look at it. Again it's in the Standard Examples of Processing, under Books/ Visualizing Data/ch03-usmap. This one is step16_lethargic. The next one I want you to take a look at, if we close that, is from hierarchies, and what this is is a way of looking at how things are apportioned and groups that are contained within groups, contained within groups. In this particular example, what we're going to be looking at is the filetreemap, and that's the one that I have open right here.
A treemap is a space-filling diagram that shows hierarchical relationships. Now, in order for this one to run, you're going to have to go and download a folder from his own website. You're going to need to download the treemap library and the place you go for that--I'll just show it you in a web browser--is to his own web page, benfry.com/writing/treemap, and that brings up this page that says Treemap Library.
What you need to do is go to the second paragraph and click on where it says library zip. That will download a folder for you and put it in your Downloads, and it shows up first at library, but if you double-click on that, it says treemap. And then what you need to do is need to go to your Sketchbook folder in Processing and find your library folder. Mine is right here. I have it under Documents/ Processing. And then you just drag it in. Then you need to quit and reopen Processing, and then the treemap library will be functional in there.
And what you find, when you open that one, is you get this program that's going to look at the size of files on your computer disk in the folder that you designate. Now, it also runs at a rather high resolution natively, 1024 x 768. So, for right now I've just bumped it down to 800 x 600 so it all fits on the screen. And here's how it works. You click Run, choose a folder. I'm going to go--so I'm going to go to the desktop here and just choose my Exercise Files folder that I have created for this course, and I'll press Open.
There we have 14_02, 14_03. And I'm just going to double-click on this one. And this breaks it up into its constituent pieces, and you can see how big each of the files is relative to each other. So, this is--again, it's called a treemap. It's an interesting way of looking at relative sizes and how things are nested within each other. It is, however, very complicated coding. You'll notice that we have 1, 2, 3, 4, 5 separate tabs in this one, as well as an external library.
That's why instead of me demonstrating how to create it, I simply want you to be aware that it exists, and I'd encourage you to look at Ben Fry's book and add the sample code that he has provided in Processing to figure that one out. The last one I want to show you very quickly is under graphlayout. A graph means also a network diagram. And I'm going to show you this one that, right now it bounces around a fair amount. It's little weird. But what it's doing is it's taking the text from Huckleberry Finn and it's showing the relationship between the words. Again, this is another wonderful piece by Ben Fry.
It's from his book, and it's included in the Standard Examples in Processing. And all I want to do is run it and show you how it connects things. Now, we think there maybe some little funky right here, that's I'm just clicking and dragging each of these pieces around, but it shows the relationships between words. Anyhow, this is a network diagram. It can be used with social networks. It can be used with telephone calls. It can be used with anything that connects with other things: scientific publications that connect through referencing to other ones, people who register in same courses together.
Anyhow, this is an elaborate version, and really an advanced topic, but something that I want you to be aware that it exists and that you can explore, especially in consultation with Ben Fry's excellent book, Visualizing Data.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 105295 Viewers
56 Video lessons · 117045 Viewers
71 Video lessons · 86250 Viewers
131 Video lessons · 41228 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.