7 Days of Source Day #2: NYTimes 365/360

NYTimes: 365/360 - 2009 (in color)

Project: NYTimes 365/360
Date: February, 2009
Language: Processing
Key Concepts: Data Visualization, NYTimes Article Search API, HashMaps & ArrayLists

Overview:

Many have you have already seen the series of visualizations that I created early in the year using the newly-released New York Times APIs. The most complex of these were in the 365/360 series in which I tried to distill an entire year of news stories into a single graphic. The resulting visualizations (2009 is picture above) capture the complex relationships – and somewhat tangled mess – that is a year in the news.

This release is a single sketch. I’ll be releasing the Article Search API Processing code as a library later in the week, but I wanted to show this project as it sits, with all of the code intact. The output from this sketch is a set of .PDFs which are suitable for print. Someday I’d like to show the entire series of these as a set of 6′ x 6′ prints – of course, someday I’d also like a solid-gold skateboard and a castle made of cheese.

That said, really nice, archival quality prints from this project (and the one I’ll be releasing tomorrow) are for sale in my Etsy shop. I realize that you’ll all be able to make your own prints now (and you are certainly welcome to do so) – but if you really enjoy the work and want to have a signed print to hang on your wall, you know who to talk to.

Getting Started:

Put the folder ‘NYT_365_360′ into your Processing sketch folder. Open Processing and open the sketch from the File > Sketchbook menu. You’ll find detailed instructions in the header of the main tab (the NYT_365_360.pde file).

Thanks:

Most of the credit for this sketch goes to the clever kids at the NYT who made the amazing Article Search API. This is the gold standard of APIs, and really is a dream to use. As you’ll see if you dig into the code, each of these complicated graphics is made with just 21 calls to the API. I can’t imagine the amount of blood, sweat, and tears that would go into making a graphic like this the old-fashioned way.

Speaking of gold standards, Robert Hodgin got me pointed to ArrayLists in the first place, and has been helpful many times over the last few years as I’ve tried to solve a series of ridiculously simple problems in Processing. Thanks, Robert!

Download: NYT365.zip (140k)


CC-GNU GPL

This software is licensed under the CC-GNU GPL version 2.0 or later.

Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL.

22 Comments

  1. clay
    Posted October 12, 2009 at 1:25 pm | Permalink

    I think you forgot to add the link to the source code! Thanks for posting this! I'm trying to learn to program and seeing code really helps.

  2. Posted October 12, 2009 at 4:51 pm | Permalink

    Fixed!

  3. thomas
    Posted October 12, 2009 at 1:33 pm | Permalink

    Thank you for great blog, it´s a great help!

    The link works fine, but the folder behind it is empty.

  4. Posted October 12, 2009 at 6:35 pm | Permalink

    Really? Works fine for me – try it again. If it doesn't work, send me an e-mail and I'll fire you the .ZIP file.

    -Jer

  5. Posted October 12, 2009 at 4:50 pm | Permalink

    Are you a professional journalist? You write very well.

  6. thomas
    Posted October 12, 2009 at 9:04 pm | Permalink

    Got it working! It was some strange Windows based problem with the zip-file.

    Sorry that I bothered you.

  7. jake
    Posted October 14, 2009 at 2:44 pm | Permalink

    I think I am having the same problem as Thomas with the zip file. It may or may not be due to the colon placed in the file name, which I think is generally not allowed in Windows. The unzipping utilities will not process anything with an invalid file name – Thomas how did you get around this?

  8. Posted October 14, 2009 at 7:58 pm | Permalink

    Hi,

    I've rebuilt the .ZIP file – hopefully it will work better, now!

    -Jer

  9. thomas
    Posted October 16, 2009 at 5:59 am | Permalink

    jake: I unzipped the file with 7-zip.

  10. yunhancai
    Posted January 20, 2010 at 11:53 pm | Permalink

    Hi, sorry to bother you, i downloaded your files, but when i open the patch, an error accord

    in the;

    String JSONStr = join(loadStrings(url), "");

    so i entered:

    String JSONStr = join(loadStrings(url), "http://query.nytimes.com/search/sitesearch?query=jobs&less=multimedia&more=date_all&quot ;) ;

    but it still says:

    NullPointerException

    can you please help?

  11. sushimo
    Posted March 17, 2010 at 9:31 pm | Permalink

    hi, same problem with null pointer exception ? Did you find any solution

  12. Posted April 16, 2010 at 11:50 am | Permalink

    too much symmetry. not really

  13. theseason
    Posted April 20, 2010 at 8:25 pm | Permalink

    Ok, so I get the sketch running but hit the wall…
    font = createFont("Meta-Normal", 100);

    It says it cannot use that font with PDF Export. It is in the data folder. I try to change simply to Helvetica, and still it doesn't work.

  14. Posted April 20, 2010 at 8:32 pm | Permalink

    Hmm.

    If you open a new sketch and just try this:

    PFont myFont = createFont(\”Helvetica\”, 100);

    Does that work?

    -Jer

  15. Posted April 23, 2010 at 12:46 am | Permalink

    same wall here with the font meta-normal cannot be used with pdf export?

  16. hagbard
    Posted April 23, 2010 at 6:28 pm | Permalink

    hi , I get the same font error here as well, the following lines

    Use PGraphicsPDF.listFonts() to get a list of available fonts.
    processing.app.debug.RunnerException: RuntimeException: The font “Meta-Normal” cannot be used with PDF Export.

  17. Posted April 23, 2010 at 6:46 pm | Permalink

    hi I get a similar font problem…..here is the error
    many thanks

    Use PGraphicsPDF.listFonts() to get a list of available fonts.
    processing.app.debug.RunnerException: RuntimeException: The font “Meta-Normal” cannot be used with PDF Export.

  18. Posted April 30, 2010 at 11:02 am | Permalink

    I just tried using: font = createFont("Arial", 100)

  19. Heidi Hysell
    Posted June 6, 2010 at 7:44 pm | Permalink

    Just wanted to post a comment so that others might know for future use. While poking around with this project I tried running the code and received notification from NYT that I've exceeded their queries per minute – will be throttling the requests in the code; let me know if you would like the update to the code with the throttling and I'll pass it along. Also I'm considering setting up a quick proxy for dev so I'm not always hitting their api. I can post a quick php file for that as well if anyone else is interested.

    Thanks,
    Heidi

  20. Aaron
    Posted August 24, 2010 at 12:57 pm | Permalink

    Heidi, That would be great!

  21. John
    Posted March 13, 2011 at 1:06 am | Permalink

    Help?

    java.io.IOException: Server returned HTTP response code: 403 for URL: http://api.nytimes.com/svc/search/v1/article?quer…
    at sun.net .www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
    at java.net.URL.openStream(URL.java:1010)
    at processing.core.PApplet.createInputRaw(PApplet.java:4532)
    at processing.core.PApplet.createInput(PApplet.java:4500)
    at processing.core.PApplet.loadStrings(PApplet.java:4785)
    at NYT_365_360$TimesArticleSearch.doSearch(NYT_365_360.java:482)
    at NYT_365_360.connectYear(NYT_365_360.java:142)
    at NYT_365_360.setup(NYT_365_360.java:116)
    at processing.core.PApplet.handleDraw(PApplet.java:1583)
    at processing.core.PApplet.run(PApplet.java:1503)
    at java.lang.Thread.run(Thread.java:680)
    The file "http://api.nytimes.com/svc/search/v1/article?query=%20publication_year:1984%20desk_facet:Foreign+Desk&fields=+&facets=per_facet,org_facet&api-key=e46*****************************" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
    processing.app.debug.RunnerException: NullPointerException
    at processing.app.Sketch.placeException(Sketch.java:1543)
    at processing.app.debug.Runner.findException(Runner.java:583)
    at processing.app.debug.Runner.reportException(Runner.java:558)
    at processing.app.debug.Runner.exception(Runner.java:498)
    at processing.app.debug.EventThread.exceptionEvent(EventThread.java:367)
    at processing.app.debug.EventThread.handleEvent(EventThread.java:255)
    at processing.app.debug.EventThread.run(EventThread.java:89)
    Exception in thread "Animation Thread" java.lang.NullPointerException
    at processing.core.PApplet.join(PApplet.java:5841)
    at NYT_365_360$TimesArticleSearch.doSearch(NYT_365_360.java:482)
    at NYT_365_360.connectYear(NYT_365_360.java:142)
    at NYT_365_360.setup(NYT_365_360.java:116)
    at processing.core.PApplet.handleDraw(PApplet.java:1583)
    at processing.core.PApplet.run(PApplet.java:1503)
    at java.lang.Thread.run(Thread.java:680)

  22. johnn
    Posted March 13, 2011 at 1:37 am | Permalink

    I found a solution. If you go to processing tools > create font you see a list of fonts. Pick one of the adobe____ fonts and that should work?

4 Trackbacks

  1. By NYT 2009 « Run, Motherfucker, run on October 14, 2009 at 10:46 am

    [...] to distill an entire year of news stories into a single graphic. The resulting visualizations (2009 is picture above) capture the complex relationships – and somewhat tangled mess – that is a year in the [...]

  2. By Code & form » Jer Thorp’s 7 Days of Code on October 14, 2009 at 5:27 pm

    [...] Jer Thorp: NY Times visualization [...]

  3. [...] her path to use Processing to visualise the agencies and functions in a spectacular array based on NYTimes 365/360 by Jer Thorp – again, click to download the full [...]

  4. By Project: NYTimes 365/360 « showingnottelling on July 7, 2011 at 12:19 pm

    [...] One of a series of visualizations created using the New York Times APIs that plot the complex relationships between news stories over the course of a year. This graphic is for 2009. [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*