Archive for September, 2007

Serving mercurial with mod_wsgi

Monday, September 17th, 2007

Here’s a quick and easy recipe for serving a mercurial repository with mod_wsgi.

  1. Create a file called hgwebdir.wsgi with these contents:

    from mercurial.hgweb.request import wsgiapplication
    from mercurial.hgweb.hgwebdir_mod import hgwebdir
    
    def make_web_app():
        return hgwebdir("/path/to/hgweb.config")
    
    application = wsgiapplication(make_web_app)
    
  2. Add it to the apache configuration:

    WSGIScriptAlias /hg /path/to/hgwebdir.wsgi

  3. [optional] To make sure nobody modifies your repository via the http interface, add ‘deny_push = *’ to the ‘[web]‘ group of hgweb.config.

Hopefully this page will save the next person a few minutes of searching.

etframes: Applying the ideas of Edward Tufte to matplotlib

Monday, September 3rd, 2007

Edward Tufte is a professor and author known for his excellent (and beautiful!) books on the visual display of statistical information. Last year I had the opportunity to attend one of his courses and was inspired to apply his ideas to my favorite plotting library, matplotlib.

The result is etfames, a python module that operates on matplotlib plots. So far I’ve implemented two graph types described in the The Visual Display of Quantitative Information (VDQI): the dash-dot-plot and range frames.

Dash Dot Plot

A dash-dot-plot places a tick mark on the axis for each value in a scatter plot. When there are many values in the graph this can be a more effective way to understand their distribution than looking at the raw data. For example:

Example of a dash-dot-plot

See demo_ddp.py for a working example.

Range Frames

The range frame re-uses the frame (edge) of a graph to display useful information. Instead of drawing a full frame around the graph the frame is only drawn from the minimum to the maximum value along that axis. For example:

Example of a range frame

See demo_range.py for a working example.

Other Work

There are several other graph types described in VDQI that would be nice to implement, particularly the extension of range frames that turns them into a box plot.

A related project is sparkplot which uses the matplotlib library to create sparklines.