[IPython-User] Subplot legend not working on embedded plots?

Matthias BUSSONNIER bussonniermatthias@gmail....
Wed Jul 25 13:38:29 CDT 2012


Le 25 juil. 2012 à 20:29, Adam Hughes a écrit :

> Thanks.
> 
> That does work correctly for me; however, is printing the string "mydata" for the name of each line.
... i'm not quite sure I understand what you want to do...

fig, ax=plt.subplots(1, figsize=(5,5) )

x,y = range(10),range(10)
ax.plot(x,y,label='mydata')

x,y = range(0,10),range(1,11)
ax.plot(x,y,label='mydata2')

x,y = range(0,10),range(2,12)
ax.plot(x,y,label='mydata3')

ax.legend()

give me 3 different labels
-- 
Matthias

>  Do you know offhand how to get it to understand a list of strings?  I'll look through the matplotlib docs further.
> 
> On Wed, Jul 25, 2012 at 2:19 PM, Matthias BUSSONNIER <bussonniermatthias@gmail.com> wrote:
> 
> Le 25 juil. 2012 à 20:14, Adam Hughes a écrit :
> 
> > Hi,
> >
> > I'm using notebook with inline plots:
> >
> > ipython notebook --pylab inline
> >
> > And noticed that if I create a subplot, then try to add a legend using ax.legend(), the legend doesn't appear.
> >
> > something like:
> >
> > fig, ax=plt.subplots(1, figsize=(12,12) )
> > ax.plot(x,y)
> > ax.legend()
> 
> By setting a label in plot(), this works for me :
> 
> fig, ax=plt.subplots(1, figsize=(5,5) )
> x,y = range(10),range(10)
> ax.plot(x,y,label='mydata')
> ax.legend()
> 
> --
> Matthias
> 
> >
> >
> > Am I doing something incorrectly or is this a known bug?
> > _______________________________________________
> > IPython-User mailing list
> > IPython-User@scipy.org
> > http://mail.scipy.org/mailman/listinfo/ipython-user
> 
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
> 
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user



More information about the IPython-User mailing list