# Day 09

Tuesday, Feb 28, 2017

# Turning off annoying features of Jupyter notebook

On Linux (Ubuntu 16.04), I created two files in ~/.jupyter/custom/ as follows to turn off prompts and automatic brackets and quotes. (~ means my home folder) These customizations appear to apply both to my native installation and to anaconda.

~/.jupyter/custom$ls custom.css custom.js ~/.jupyter/custom$ cat custom.js
IPython.CodeCell.options_default.cm_config.autoCloseBrackets = false;

~/.jupyter/custom\$ cat custom.css
div.prompt { display: none; }


# XML, cont'd

## Another example of an XML format

Files stored in these formats are actually zipped archives with most of the data stored as XML.

## XML Exercise 2

Create a small LibreOffice or OpenOffice Writer document, or Microsoft Word document. Save it. Rename it something.gz. Unzip it and examine the contents.

## Exercise XML 1c: How would your XML document look in JSON?

How would the above all work using JSON instead of XML? Replicate Exercise XML 1a/b with JSON (manually type the analogous json document, and parse it with python).

# RGB color and color maps

## RGB color

Look at color selector in Inkscape or other graphics program.

python hex

function to generate #XXXXXX representation

## SVG Exercise 1

Generate an SVG file that represents a collection of randomly sized, placed and colored circles. Use simple.svg as a prototype.

## Color maps

These are maps (functions) from your data space to color space.

Linear segmented (i.e. piecewise linear) color maps also widely used.

2D color maps (from 2D data to a 2D surface in color space) also possible.

Let's make a color map generator and try it out!

# Choropleth maps

From Wikipedia: A choropleth map (from Greek χῶρος ("area/region") + πλῆθος ("multitude")) is a thematic map in which areas are shaded or patterned in proportion to the measurement of the statistical variable being displayed on the map, such as population density or per-capita income.

## SVG Exercise 2: Highlight Erie County on a US map

Save this blank map of US counties to a local folder

Edit it with a text editor (gedit, brackets, atom, vi, emacs, sublimetext, etc.),

and ...

Color the county where you were born with some bright color of your choice, and check it in your browser. If you were not born in the USA, consider yourself an honorary Erie County native.

## SVG Exercise 3: Parse an SVG file

In Python, do a little parsing of the SVG file: see if you can read (and re-write) the attributes of the elements. For example, how about coloring each county at random?

# Report 2: Choropleth map of US

## Find some interesting data for every county in the US

Search online for some data given for every county in the nation.

You may want to consult this page about the FIPS codes for counties. Fall-back suggestion if you don't find anything else good: annual unemployment data from the US Bureau of Labor Statistics.

## Color the counties on the map according to your data

This may require some thought, some research, and some work. Although you are welcome to consider elaborate color maps (even 2D maps representing two quantities), you should beware of creating graphics that are strikingly colorful but difficult for the viewer to interpret. Simple things like a white-to-red gradient can be very effective: the picture below shows the fraction of the population that is of African descent (generated by a student in this class in 2015).