Legends Outside of the Graph

Hello,

Does anyone know of a way to create a legend outside the bounds of the graph? I have a stacked area chart that doesn't have any spare room. When matplotlib draws the legend it obscures the data! I looked through the available documentation and didn't see any way around this. Does anyone have any tricks that might work?

Tony Rippy

Does anyone know of a way to create a legend outside the bounds of the graph? I have a stacked area chart that doesn't have any spare room. When matplotlib draws the legend it obscures the data! I looked through the available documentation and didn't see any way around this. Does anyone have any tricks that might work?

checkout figlegend_demo.py in the matplotlib examples...

more trivial example:

#!/usr/bin/env python
from pylab import *
x=arange(0, 6, 0.1)
y=sin(x)
figure(figsize=(11,6))
axes([0.075, 0.10, 0.55, 0.78])
lines=plot(x,y)
figlegend((lines,), ("i'm outside!",), 'upper right')
show()

can play with axes/figsize if you've got long names

cheers,

···

--
Peter Groszkowski Gemini Observatory
Tel: +1 808 9742509 670 N. A'ohoku Place
Fax: +1 808 9359235 Hilo, Hawai'i 96720, USA

That did the trick... Thank you very much!

Tony

Peter Groszkowski wrote:

···

Does anyone know of a way to create a legend outside the bounds of the graph? I have a stacked area chart that doesn't have any spare room. When matplotlib draws the legend it obscures the data! I looked through the available documentation and didn't see any way around this. Does anyone have any tricks that might work?

checkout figlegend_demo.py in the matplotlib examples...

more trivial example:

#!/usr/bin/env python
from pylab import *
x=arange(0, 6, 0.1)
y=sin(x)
figure(figsize=(11,6))
axes([0.075, 0.10, 0.55, 0.78])
lines=plot(x,y)
figlegend((lines,), ("i'm outside!",), 'upper right')
show()

can play with axes/figsize if you've got long names

cheers,