Because I’m in the field, I frequently get e-mails with links to extraordinarily creative data visualizations. I generally have two reactions: First, I usually think “wow, that’s exceedingly clever!”, usually followed shortly by “hmm, I bet that visualization would work really well for showing ….” But then the follow-through for my second reaction hardly ever occurs because other distractions set in. The high level of abstraction in Brunel Visualization gave us the opportunity to enable any Brunel syntax to easily be applied to different data. (For some examples of different visualizations, check out Working Vis.) We can simply look through actions from one visualization and replace data variables with others that have similar statistical properties (or additional criteria, as we make improvements) from a different data set. For example, one of our gallery visualizations shows how many board games by category that have been published over the years; overlaid are the top actual games sized by the number of votes they received. (Click the image to go to the live visualization; use the Data menu option to add your own data in the form of a CSV file.) Image of a Brunel visualization Let’s say I would like to re-purpose this same visualization technique to show the carbon emissions of the top economies over time. The Gapminder website has a nice collection of data about countries, including “CO2 emissions (tonnes per person)” which was provided by the Carbon Dioxide Information Analysis Center (CDIAC). First, we need to do a bit of data reshaping to columnar form and some filtering for the countries we want to include — pretty simple to do in Python within a Jupyter Notebook: [code language=”python”] import pandas as pd #read the data co2 = pd.read_csv("data/indicator CDIAC carbon_dioxide_emissions_per_capita.csv") #define large economies large_economies=["United States", "China", "Japan", "Germany", "United Kingdom", "France", "India", "Brazil", "Italy", "Canada"] #reshape the data co2 = pd.melt(co2, id_vars=["CO2 per capita"], var_name="Year") #filter co2 = co2.loc[co2[‘CO2 per capita’].isin(large_economies)] #write out as CSV co2.to_csv("data/Co2.csv", index=False) [/code] The code above writes the transformed data to a CSV file, which can then be uploaded to the service and resulting in a new Brunel visualization using the emissions data instead of the game data. All that’s left to do is cut and paste this Brunel syntax back into my Jupyter Notebook and remove the “data()” statements, since I want this to use the data from my notebook. A few more trivial changes to the Brunel code (adjusting the text on the tooltip, removing the summation that isn’t important here, and so on) yields a graph showing carbon emissions for each country over time with the largest emissions values overlaid as points — and with working tooltips too! [code language=”python”] import brunel % brunel path x(Year) y(CO2_per_capita) color(CO2_per_capita) size(value:200) top(Year:1800) legends(none) + x(Year) y(CO2_per_capita) size(value:300) tooltip(CO2_per_capita, ‘: ‘, value) top(Year:1800, value:20) :: width=900, height=450 [/code] Image of a Brunel visualization Here’s another use of the same visualization, but this time modified to become more interactive. After we again replace the data from the original gallery visualization and make some minor modifications to the resulting Brunel, we examine my colleague Graham’s tastes in music from different eras using data from his iTunes. The lines are now sized by the number of times he has played songs within each genre, and the top 20 songs are overlaid. A slider allows us to change the display based on how he has rated his songs. (Note: If the following visualization does not appear in your browser, try viewing it here.) https://brunel.mybluemix.net/brunel/interpret/d3?brunel_src=data('http%3A%2F%2Fbit.ly%2F1PQlGXM')%20path%20x(Year)%20y(Genre)%20color(Genre)%20size(Play_Count%3A200)%20sum(Play_Count)%20legends(none)%20%2B%20data('http%3A%2F%2Fbit.ly%2F1PQlGXM')%20x(Year)%20y(Genre)%20size(Play_Count%3A300)%20filter(Rating)%20tooltip(Name%2C%20'%3A%20'%2C%20Artist%2C%20'%20(Play%20Count%3A%20'%2C%20Play_Count%2C%20')')%20top(Play_Count%3A20)%20sum(Play_Count)&width=775&height=435 [code language=”python”] data(‘http://bit.ly/1PQlGXM’) path x(Year) y(Genre) color(Genre) size(Play_Count:200) sum(Play_Count) legends(none) + data(‘http://bit.ly/1PQlGXM’) x(Year) y(Genre) size(Play_Count:300) filter(Rating) tooltip(Name, ‘: ‘, Artist, ‘ (Play Count: ‘, Play_Count, ‘)’) top(Play_Count:20) sum(Play_Count) [/code] This technique won’t always give the perfect replication, but it should give you enough information to get started and add your own personal creativity. Have fun!

2 comments on"Brunel: Imitation is a sincere form of flattery"

  1. […] See how the high level of abstraction in Brunel enables you to apply the syntax to different data […]

  2. […] See how the high level of abstraction in Brunel enables you to apply the syntax to different data […]

Join The Discussion

Your email address will not be published. Required fields are marked *