.

.

bandViz

bandViz is a python script. When you give it a wikipedia link of your favorite music band or musician, it builds you a slick graph.

intro

Let's start of with a simple example. If we plug in Nine Inch Nails and ask for a resolution of 1, the script will crawl through wikipedia, parse the relevant information and build this:

Now, lets try the same example with a resolution of 20

The resolution is directly proportional to the amount of data you see in the graph. The bigger the resolution, the more detailed your graphs will be. Also remember that plugging in a higher resolution will also take longer. The time taken also depends on your internet speed.

There are more sample graphs at the bottom of this page.

Note: bandViz does not actually generate the graph. It generates a Graphviz file which contains instructions on how to build the graph. To actually generate it graph you'll need to download Graphviz from here. Once you get it, you can use one of its several rendering engines to plot the generated data.

Usage

To use bandViz you must first import it into your file like so:

from bandviz import queuemanager

QueueManager is the only class you need to import. Once you have that you can instantiate an object of that class. Using this object you can queue up bands and artits you want to process. This is done using the addtoQueue() function.

bandViz = queuemanager.QueueManager()
bandViz.addtoQueue("http://en.wikipedia.org/wiki/Red_Hot_Chili_Peppers")

If you would like to see bands which are not currently active or see defunct artists of bands, you can enable the showFormerMembers flag. Defunct members are represented by arrows which are not filled. Note: Enabling this will make your graph bigger

If you would like bandViz to follow artist links more vigorously you can enable the expansiveArtistGraph flag. Note: This will slow down the generation process.

You can control how big the graph gets using the resolution variable. A higher value would result in a larger graph, but it also takes a longer time to generate.

bandViz.showFormerMembers = False 
bandViz.expansiveArtistGraph = False 

bandViz.resolution = 10
bandViz.printDebug = True
You can also style the graph using the following parameters. Note that these have to be accessed through the BandManager variable instance inside QueueManager. Complete stying information can be found here and here.
bandViz.bm.vizBackground = "gray90"
bandViz.bm.vizArrowColor = "gray43" 
bandViz.bm.vizBandBackgroundColor = "gray43"
bandViz.bm.vizBandShape = "egg" 
bandViz.bm.vizBandFontColor = "white"
bandViz.bm.vizArtistBackgroundColor = "gray"
bandViz.bm.vizArtistShape = "ellipse"
bandViz.bm.vizArtistFontColor = "black"

And finally you can start the process using the start() function. This function returns the total time elapsed for the process.

Here is the full example

#!/usr/bin/env python

import os
from bandviz import queuemanager

os.system("clear")

bandViz = queuemanager.QueueManager() #initialize bandViz

#add artist/bands to queue
bandViz.addtoQueue("http://en.wikipedia.org/wiki/Red_Hot_Chili_Peppers")

#name of output graphViz file; will overwrite if already exists.
bandViz.bm.vizOutpuFileName = "example.gv" 

#graph colors and properties.
#complete list of colors @ http://www.graphviz.org/doc/info/colors.html
#complete list of node shapes @ http://www.graphviz.org/doc/info/shapes.html
bandViz.bm.vizBackground = "gray90"
bandViz.bm.vizArrowColor = "gray43" 
bandViz.bm.vizBandBackgroundColor = "gray43"
bandViz.bm.vizBandShape = "egg" 
bandViz.bm.vizBandFontColor = "white"
bandViz.bm.vizArtistBackgroundColor = "gray"
bandViz.bm.vizArtistShape = "ellipse"
bandViz.bm.vizArtistFontColor = "black"

#enable this to make it show defunct members of band and defunct bands.
#enabling this will your graph bigger.
bandViz.showFormerMembers = False 

#enable this if you want to increase priority of fetching artists.
#enabling this will follow every artist link, ie. it increases your queue size.
bandViz.expansiveArtistGraph = False 

#resolution. Increase this to increase the size of your graph
#warning: higher resolutions take longer
bandViz.resolution = 10

#enable printDebug to make bandViz print the entity its currently processing
#onto the console
bandViz.printDebug = True

#start the process! It returns an int of the time elapsed in secs.
totalTime = bandViz.start() 

#show time elapsed
min = round(totalTime/60,1)
print "\nFinished in " + str(totalTime) + " seconds. (" + str(min) + " mins)\n"
print "Graphviz file written to 'example.gv'\n"

Download

This is an open source project and its stored on a git repository at:

The latest builds can be found there. This is my first actual python project, so please be kind. If you want to collaborate or fork, you are very welcome.

Gallery

Here are some images generated through bandViz. If you have a good one send it to colorfulgrayscale@gmail.com and I'll get it up on here.

Note: These images are huge, they average size is around 3500 pixels. To effectively discern the text in the graph, you might want to Right Click -> Save image to your computer. Then open it so that you can zoom and pan.