One legend, two axes?

Skip,You can call figlegend() and build a legend for the figure,
irrespectively of any axes.

Thanks. Sounds like exactly what I need.

Skip

Skip Montanaro, on 2010-12-15 12:49, wrote:

> Skip,You can call figlegend() and build a legend for the figure,
> irrespectively of any axes.

Thanks. Sounds like exactly what I need.

Hi Skip,
I just wanted to chime in and give you a concrete example of how
you can get all of the line instances from one axes and include
them in the legend of another, or in a figlegend:

  ax = plt.subplot(1,2,1)
  ax2 = plt.subplot(1,2,2)
  ax.plot([0,1], label='ax1')
  ax2.plot([4,3], 'r--',label='ax2')
  lines =ax.get_lines()
  lines.extend(ax2.get_lines())
  labels = [l.get_label() for l in lines]
  leg = ax.legend(lines, labels)
  # or, alternatively...
  leg2 = plt.figlegend(lines,labels,loc='center')

this is a slight revision to what was previously discussed here:
<http://old.nabble.com/aligning-multiple-legends-td29638901.html>

···

--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7