From: John H. <jdh...@ac...> - 2004-05-12 11:35:45
|
>>>>> "Jim" == Jim Benson <jb...@se...> writes: Jim> a.legend(('aLabel'), 'upper center') Jim> a.set_xlim(xRangeList) a.set_ylim(yRangeList) Jim> # End of: for yList in yLists: Jim> self.toolbar.update() Jim> The aLabel gets printed like: a L a b e l That's because ('a label') is a string and not a tuple. I should test for this and raise, since it gets me too sometimes. The legend code is iterating over the string effectively making each character a separate legend entry. You need ('a label',); note the comma makes it a length 1 tuple of strings. Jim> I would really like to specify that the legend appear off of Jim> the plot...say to the left of the y axis tick marks...any Jim> hints here? fig.legend works just like ax.legend, where fig is a Figure instance. (figlegend in the matlab interface). The placement commands are the same, eg 'upper right', but this is in the upper right of the figure rather than the axes. You can add as many legends as you want this way. You have to pass it the lines or rectangles (also as a tuple) that you want to make the legend for, because unlike axes legends, it can't use introspection to guess which lines you want to make a legend for - well, it could but it doesn't. Note if you want to resize the axes so that is doesn't overlap the legend you create, you may want to use Axes rather than subplot, in which you can supply an explicit left, bottom, width, height tuple for the axes dimensions, as in axes_demo.py. JDH |