bizarre legend behavior

John,

First things first. Thanks for all your help. I wasn't aware of the
figlegend command (even though it is clearly in the documentation). I
can do what I want with figlegends althought it takes some fiddling to
get the positions right. I have to use explicit coordinates because the
legends are referenced to the figure not the axes so the boxes don't
default to lying inside the graphs and cross over the axes boundaries.
In addition the legends are in separate boxes with figlegend, which is
acceptable, but not necessarily optimal. I did run into another problem
using figlegend, namely that I can't get a handle to the legend text so
I'm not able to set the fontsize. I'd appreciate it if you could
illuminate me with how to set fontsize in a figlegend.

So, on to other things. I cooked up an example that shows what I was
originally trying to do. I have two routines, doPlots1 and doPlots2,
that do exactly the same thing. The only difference is in the default
arguments, which I don't actually set, I just use the default. Figure 1
has the effect I was looking for, although I for the life of me don't
understand why the two routines give difference answers, or for that
matter, why figure 1 works the way it does.

In any case. Figure 1 is what I was shooting for. If you want to post
some reliable code that does this, I'd appreciate it.

Danny

# %< -----------------------------------------------------
from matplotlib.matlab import *
import Numeric as N

def doPlots1(const,color,legendList=[],legendTextList=[]):
  y1=N.arange(0., 10, 1)+ const
  x = arange(len(y1))
  
  ln1 = plot(x,y1,color+'+-')
  legendList.append(ln1)
  legendTextList.append('line1')
  
  y2 = y1 + 1
  ln2 = plot(x,y2,color+'^-')
  legendList.append(ln2)
  legendTextList.append('line2')

  legend(legendList,legendTextList)
  show()
  
def doPlots2(const,color):
  legendList=[]
  legendTextList=[]
  
  y1=N.arange(0., 10, 1)+ const
  x = arange(len(y1))
  
  ln1 = plot(x,y1,color+'+-')
  legendList.append(ln1)
  legendTextList.append('line1')
  
  y2 = y1 + 1
  ln2 = plot(x,y2,color+'^-')
  legendList.append(ln2)
  legendTextList.append('line2')

  legend(legendList,legendTextList)
  show()

figure(1)
doPlots1(0,'r')
doPlots1(5,'b')

figure(2)
doPlots2(0,'r')
doPlots2(5,'b')

···

__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail