legends

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?

JDH

# Thanks to Charles Twardy
from matplotlib.matlab import *

a = arange(0,3,.02)
b = arange(0,3,.02)
c=exp(a)
d=c.tolist()
d.reverse()
d = array(d)

ax = subplot(111)
plot(a,c,'k--',a,d,'k:',a,c+d,'k')
legend(('Model length', 'Data length', 'Total message length'), 'upper right')
ax.set_ylim([-1,20])
ax.grid(0)
xlabel('Model complexity --->')
ylabel('Message length --->')
title('Minimum Message Length')
set(gca(), 'yticklabels', [])
set(gca(), 'xticklabels', [])

savefig('mml')
show()

}done in CVS now and tested with the 3 backends.

Now _that's_ service! :slight_smile: :slight_smile: :slight_smile:

Sounds like your implemention makes much more sense, as expected.

}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?
I'd be honored!

Waiting for my cvs mirror to catch up....
  -C

···

On Tue, 30 Sep 2003, John Hunter wrote:

--
Charles R. Twardy, Res.Fellow, Monash University, School of CSSE
ctwardy at alumni indiana edu +61(3) 9905 5823 (w) 5146 (fax)

"in much of the rest of the world, rich people live in gated
communities and drink bottled water." --Jared Diamond