We need modules from the Bokeh library, Datashader, NumPy, Pandas, and pyproj, as well as the Data Lab modules to connect to the database.

In [1]:

print"Start"importbokeh.plottingasbpfromdatashader.bokeh_extimportInteractiveImagefrompyprojimportProjimportnumpyasnpfromcStringIOimportStringIOfromdlimportauthClientfromdlimportqueryClientimportpandasaspdimportdatashaderasdsimportdatashader.glyphsimportdatashader.transfer_functionsastf# Get the security token for the datalab demo usertoken=authClient.login('anonymous')print"Got token",token

Datashader creates a canvas from the two-dimensional data that you select, aggregates the data, and then uses a transfer function to map the aggregated data onto the canvas. In one fell swoop, limited to Field 169:

Here we break down Datashader's steps and a couple of more parameters, such as specifying a log stretch in the transfer function and use our Blue/Red category in making the aggregate. We'll also spread the points out a bit to make theam easier to see. There are many more parameters decribed in the Datashader documentation.

We can combine Datashader with Bokeh's interactive plotting to make a dynamic density map of our entire SMASH query result. The code below makes use of Datashader's dynamic spread transfer function, which gives the map variable resolution as a function of zoom level. Try the Wheel Zoom function or Box Zoom to zoom in on a particular field. The field at (-4,-7.5) has a couple of background galaxy clusters in it.