Scale legend box border, dashed and dotted lines when the figure size is changed


I posted this to stackoverflow
but didn't get any answer, so here goes again:

I'm trying to use matplotlib to prepare some figures for publication.
In order to make the font sizes match the text of the manuscript I'm
trying to create the figure in the final size to begin with, so that I
avoid scaling the figure when inserting it into the manuscript.

The problem I'm having is that as the figure is then pretty small, I
can scale font sizes, axis sizes, line widths etc., but what I've been
unable to figure out is how to scale dashed or dotted lines, as well
as the thickness of the legend border box. For a simplified and
somewhat exaggerated example, consider


small = True

from matplotlib import use

from matplotlib import rc
rc('ps', usedistiller='xpdf')
rc('text', usetex=True)

if small:
   figsize = (1.0, 0.5)
   rc('font', size=2)
   rc('axes', labelsize=2, linewidth=0.2)
   rc('legend', fontsize=2, handlelength=10)
   rc('xtick', labelsize=2)
   rc('ytick', labelsize=2)
   rc('lines', lw=0.2, mew=0.2)
   rc('grid', linewidth=0.2)
   figsize = (8,8)

import numpy as np

x = np.arange(0, 10, 0.001)
y = np.sin(x)

import matplotlib.pyplot as plt
f = plt.figure(figsize=figsize)
a = f.add_subplot(111)
a.plot(x, y, '--', label='foo bar')

If you change the first executable line to small = False you can see
how it should look in "normal" size. Compared to the normal size, the
small plot suffers from a legend box with too thick borders, and the
dashed line is too coarse, i.e. too long dashes and too long distance
between the dashes.

So my question is, is there a way to fix these two problems?

The matplotlib version I'm using is on ubuntu 10.04 amd64.


Janne Blomqvist