Interactive Data Visualization with Processing
Illustration by Neil Webb

Making line plots


Interactive Data Visualization with Processing

with Barton Poulson

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Video: Making line plots

- If you have a variable that changes over time, one very good way of looking at this is with what's sometimes called a time plot or an area chart or just a line chart, and in this movie, I'm going to show you how to produce a variation on the line chart that does a really good job of drawing changes and interest and in particular, Google search term over time. Now, in this one, I've got my palette there up at the top. Then, I call two fonts because I'm gonna be using one for the titles and one for the labels.
Expand all | Collapse all
  1. 3m 16s
    1. Welcome
    2. What you should know
      1m 22s
    3. Using the exercise files
  2. 11m 51s
    1. Overview of data visualization
      11m 51s
  3. 11m 53s
    1. Installing Processing
      3m 38s
    2. Overview of Processing
      4m 5s
    3. Exploring libraries
      4m 10s
  4. 1h 1m
    1. Basic setup
      7m 31s
    2. Drawing points
      4m 37s
    3. Drawing lines
      5m 6s
    4. Drawing ellipses and circles
      5m 24s
    5. Drawing arcs
      6m 54s
    6. Drawing rectangles and squares
      4m 58s
    7. Drawing quadrangles
      3m 25s
    8. Drawing triangles
      2m 55s
    9. Drawing polygons
      3m 37s
    10. Drawing simple curves
      4m 54s
    11. Drawing complex curves
      6m 46s
    12. Drawing Bézier curves
      5m 38s
  5. 54m 3s
    1. Introduction to variables
      10m 44s
    2. Understanding variable scope
      6m 53s
    3. Modifying variables
      9m 8s
    4. Creating arrays
      9m 53s
    5. Modifying arrays
      6m 37s
    6. Creating strings
      7m 3s
    7. Modifying strings
      3m 45s
  6. 1h 2m
    1. Incorporating randomness
      7m 59s
    2. Using Perlin noise
      4m 24s
    3. Shuffling with Java
      3m 30s
    4. Specifying line attributes
      8m 2s
    5. Changing placement modes
      5m 45s
    6. Understanding color attributes and functions
      4m 16s
    7. Exploring color spaces
      7m 44s
    8. Using color palettes
      7m 5s
    9. Transforming the grid
      8m 38s
    10. Exploring the attribute matrix
      5m 33s
  7. 52m 7s
    1. Building code blocks
      5m 57s
    2. Writing a while loop
      3m 52s
    3. Using for loops
      5m 35s
    4. Creating conditionals
      14m 50s
    5. Working with easing
      10m 51s
    6. Creating spirals
      11m 2s
  8. 18m 55s
    1. Mouse tracking
      3m 54s
    2. Hovering and clicking
      11m 16s
    3. Understanding keyboard interaction
      3m 45s
  9. 27m 32s
    1. Specifying fonts
      6m 43s
    2. Using images
      5m 51s
    3. Playing a video loop
      6m 20s
    4. Exporting video
      3m 47s
    5. Adding sound
      4m 51s
  10. 20m 49s
    1. Creating functions
      11m 48s
    2. Creating classes and objects
      9m 1s
  11. 31m 10s
    1. Using embedded data
      5m 26s
    2. Working with appended text data
      6m 4s
    3. Working with appended tabular data
      10m 26s
    4. Reading XML data
      9m 14s
  12. 48m 15s
    1. Generating dot plots
      11m 11s
    2. Building scatter plots
      10m 0s
    3. Making line plots
      9m 53s
    4. Creating bar charts
      9m 12s
    5. Checking out examples of maps, hierarchies, and networks
      7m 59s
  13. 20m 57s
    1. Introducing some principles of 2D design
      13m 44s
    2. Understanding color theory
      7m 13s
  14. 24m 46s
    1. Interacting with zooming, rotating, and sliding
      6m 26s
    2. Implementing slicing
      6m 47s
    3. Using rollovers
      5m 58s
    4. Introducing the GUI libraries
      5m 35s
  15. 10m 35s
    1. Sharing via OpenProcessing and other sites
      3m 19s
    2. Saving as a desktop application
      2m 42s
    3. Saving as JavaScript
      1m 47s
    4. Saving as an Android application
      2m 47s
  16. 2m 38s
    1. Where to go from here
      2m 38s

please wait ...
Watch the Online Video Course Interactive Data Visualization with Processing
7h 43m Beginner Sep 25, 2012

Viewers: in countries Watching now:

Start communicating ideas and diagramming data in a more interactive way. In this course, author Barton Poulson shows how to read, map, and illustrate data with Processing, an open-source drawing and development environment. On top of a solid introduction to Processing itself, this course investigates methods for obtaining and preparing data, designing for data visualization, and building an interactive experience out of a design. When your visualization is complete, explore the options for sharing your work, whether uploading it to specialized websites, embedding the visualizations in your own web pages, or even creating a desktop or Android app for your work.

Topics include:
  • Exploring the need for creative data visualization
  • Drawing basic lines and shapes
  • Introducing variables, strings, and arrays
  • Modifying drawing attributes such as color
  • Making drawings more dynamic with animation loops and spirals
  • Creating keyboard- and mouse-based interactions
  • Adding images, video, and sound
  • Reading in text or XML data
  • Creating plots and charts
  • Publishing and sharing your work
Developer IT
Barton Poulson

Making line plots

- If you have a variable that changes over time, one very good way of looking at this is with what's sometimes called a time plot or an area chart or just a line chart, and in this movie, I'm going to show you how to produce a variation on the line chart that does a really good job of drawing changes and interest and in particular, Google search term over time. Now, in this one, I've got my palette there up at the top. Then, I call two fonts because I'm gonna be using one for the titles and one for the labels.

Then I'm calling up some data about art. What I did is I went to Google Correlate and I got the search trends over time for the French cubist painter, Georges Braque. That's going to be the data that we're gonna use. In the Table class, I'm creating an object artData. After that, I have a rowCount, and then I had to do an interesting thing because I have two forms of interaction here. I need to create a secondary variable that can also record the mouse position, but I started just slightly off of the visualization.

After that, I have the setup block. I have a window that's 600 by 200. Then, I take my artData objects that I created earlier in the Table class and then I load the braque.tsv file into it. That's a tab-separated values file and the easiest way to get those is by opening a file in Excel and saving it as a tab-separated values text file and then manually changing the extension after you saved it. Then I have a Table function where I get the row count, then I print the row count at the bottom as a way of double-checking that I'm reading things correctly.

Then I load two fonts; a bold, 18 point Gill Sans for the titles and a regular 12 point Gill Sans for some of the labels. And again, I created these with Processing's font tool. If you go up to Tools, we have Create Font. And as I mentioned before, the fonts available on our computer and the fonts available on your computer might be slightly different. If you don't have Gill Sans, don't worry, you can either comment out those lines completely or you can replace them with fonts that you create using the ones available on your computer.

Either way would work fine. Then, last thing into the setup block is I turn on the anti-aliasing with the smooth function. Going down to draw, one of the interesting things I do here is I turn off the cursor completely. You can have a choice of the arrow cursor, a hand cursor, a crosshair cursor, the text I-beam cursor, the Spinning Beach Ball of Death wait cursor, and you also have the option of turning it off completely. Actually, you can also load an image file as a cursor, but I decided for this one to get rid of it and I'll explain that, when you see it'll make sense.

Then I put the background color in. I call up the text font and then I put in some color information for the stroke and the feel, and I'm going to center the title across the top. It says, "Google Searches for Georges Braque." Then I'm going to start aligning some other information for the labels. Let me come down here. Then I have a for loop that goes through and reads the data file. So I tell it first that I want to go through row by row starting at the very tippy top because my TSV file doesn't have any header information. It's just starts with the data.

That's one of the reasons that I save an additional version of the file with either CSV or XLS file that has the headers for reference purposes. But it says to go through and to first read the dates. I have date information with the month and year because when I went to Google Correlate, you can download either information in a week by week or month by month. The month by month is a little cleaner for this one, so that's what I chose. So that comes in in strings and then I used the getString method then I go to pull out the popularity data and that's the actual Google search relative interest in it.

Below that, as I showed in the last movie on scatterplots, I create x and y variables using Processing's map function. What that does is it's able to take the two variables about the row numbers and about popularity numbers and it's able to convert them from their existing scale, for instance for the rows, it goes from 0 to 104, and I'm able to change that to a 30 to 575 scale, to spread things out evenly. Similarly, with the popularity, it's able to take a -2 to +4 scale and it's able to spread it out from 150 to 20.

It's actually changing the direction because I want higher numbers to be higher up on the window whereas conventional computer numbering starts with lower numbers at the top and gets higher as it goes down. So this flips it around for me automatically. Then, what I have is a couple of lines that are currently commented out that I use just to check that this is working correctly. For instance, this line right here will print out 104 lines of the popularity data formatted with one digit on the right and three decimals places, and with a + or - in front of it.

Then, I've gone off to the right, it'll do a semi-colon, then it will do the converted version of the popularity where it's mapped on to the 150 to 20 scale. And so, that's just something I did to check that it was working. I also turned on noLoop 'cause I didn't want it to just keep repeating and repeating in the console, but both of those are commented out. Then, I used something called slicing for the interaction. What that does is it lets me move the cursor from left to right behind the data and I've got it set up to bring in a line and when the line gets close to one of the data values, it pops in some information about that one.

In a later movie where I talk about forms of interaction, I am gonna talk about slicing a little bit more. But, you'll see how it works. Mostly, I'm saying, only do it when we're in the data window and I want you to draw a line of a certain height, and then if it's within two pixels of a data point, then I want to fill in this information that kinda floats like a flag at the top of the line. Beneath that, I draw the lines and the dots. What I'm doing is, I'm actually drawing dots at each data point as they go across, and then I'm drawing vertical lines from the bottom up.

So this is somewhere in between sort of like a bar chart and then an area chart, but I think it makes it clear and easy to read. Also, because it I have this stuff set in, I don't need a line across the bottom. Then I have something that reads the dates. Then, what it's gonna do is it's going to put in the January. It's starting on a January 'cause the data sets starts on January. Then it skips to every 12th row, so it lets me know when the first of the year starts. Right down here, that's where it places the dates.

I have to recreate the variables here, but I do them for only every 12th case. Then what this does is this changes the way that the lines are drawn for each January. It's the same color and everything, but it's a thicker line and also, it puts a square cap on it. I don't draw the ellipses anymore. And so, it makes it a way of telling where the year starts and stops. Then finally, below that, I have two blocks that are used for interaction. The first one is about keyPressed and it actually makes it so that I can manipulate my little interaction thing with the left and right arrow keys on the keyboard.

The other one is a function we haven't seen before. It's mouseMoved and that says, this one only kicks in if the mouse is not clicked and it starts moving. There's other ways you could have done this, but this is a shortcut one. And, between the two of these, you see they're both affect the variable mx, that stands for mouseX and they both affect the same way of gliding through the data to get the values. With that, I'll scroll back up to the top and I'll click Run.

There's my data set; Google Searches for Georges Braques and you see it started January of 2004 and it goes through July or August of 2012. And I've got a thicker red line for every January so it's easy to tell where each year starts. There's a couple of things you can see here. The most important one is you see that people search for Georges Braque when school is in session. The summer months are a huge dip every single year. Also, for reasons that are not clear, it looks like George Braque's general popularity is going down over time, at least slightly.

And we also have a few big spikes. For instance, in 2007, there's a big spike in interest and there's a couple of others. But now, let me show you how we can interact with this. I'm gonna bring the mouse over. You see I've got the mouse here on the side, but as soon as it hits where the bars are, the mouse will disappear. Now, I just have a line coming through with the information for each month, as it matches up to that line. So, for December of '05, the interest in Georges Braque was at .559, so that's slightly above average.

Whereas during the summer, August of '06, it's a standard deviation below average. Then here we got this spike and we got another spike over here. I don't really know what to make of those. I also want you to see that right now, I'm driving with the mouse. But if I let go of the mouse and just hit the left key on the arrow on the keypad, now I'm driving it with the keyboard and there's the right arrow, and I can stop and I can start moving the mouse. It picks up exactly where it left off. That's a really smooth form of interaction especially 'cause it lets them go from one to the other.

It also works really well to have the cursor just be completely absent so that people can see just the data and what needs to be in there. Anyhow, this is one way to create a form of line plot or time plot as a way of showing the prevalence of a single quantitative variable as it changes over time.

There are currently no FAQs about Interactive Data Visualization with Processing.

Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed Interactive Data Visualization with Processing.

Return to your organization's learning portal to continue training, or close this page.

Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.