I couldn't see any way to do legends, so I hacked
> together a routine that worked for me. However, I don't
> know how to handle fonts properly (ie, find out how much
> plotting space they really take up), so someone might
> want to fix the two lines marked "#Hack" and maybe the
> related row spacing.
Thanks for the script. I've been meaning to add legends for some time
and you gave me the push I needed. To do it right (account for font
size) is a little more difficult so I've been putting it off, but it's
done in CVS now and tested with the 3 backends.
I added the legend functionality to the Axes class, which has the
advantage that you don't need to specify the line styles, colors
etc... since the axes contains the lines and can get them from there.
Also, I decided not to go with a whole new legend axes, but rather
added a legend patch, legend lines and legend text to the current
axis. Changes to axes lines with handle graphics or Line2D API calls
are reflected in the legend text.
Below is your script which works with the CVS version. Do you mind if
I add it to the examples dir in the matplotlib distro?
# Thanks to Charles Twardy
from matplotlib.matlab import *
a = arange(0,3,.02)
b = arange(0,3,.02)
d = array(d)
ax = subplot(111)
legend(('Model length', 'Data length', 'Total message length'), 'upper right')
xlabel('Model complexity --->')
ylabel('Message length --->')
title('Minimum Message Length')
set(gca(), 'yticklabels', )
set(gca(), 'xticklabels', )