From: John H. <jdh...@ac...> - 2004-06-02 18:57:22
|
>>>>> "Flavio" == Flavio Codeco Coelho <fcc...@fi...> writes: Flavio> Crystal! But then the legends second example(legend_demo2) Flavio> is a bit misleading since it uses the syntax I used Flavio> originally (without the subscripts). I am aware of the Flavio> difference between the two situations, but my general Flavio> point is that since the examples are one of the main Flavio> sources of instruction for users, they should be as Flavio> complete as possible, i.e. contain as many variations on Flavio> the theme as possible, don't you agree? Of course they Flavio> should not substitute the prime directive: RTFM!, but they Flavio> are a powerful tool that should be explored. Well, in this case it would be RTNYEFM (RT not-yet-existant FM) so I would hesitate to advise it. Yes, the difference in your example and the one in legend_demo2.py is that in the latter the sequence of lines returned by plot are length 1 whereas in hist they are longer. The legend code "flattens" the list of lines/patches and so consumes the sequences in order until the list of labels is exhausted. In your original example, the patches from the first hist used up all your labels. I changed legend_demo2.py to read l1, = plot(t2, exp(-t2)) l2, l3 = plot(t2, sin(2*pi*t2), '--go', t1, log(1+t1), '.') l4, = plot(t2, exp(-t2)*sin(2*pi*t2), 'rs-.') legend( (l2, l4), ('oscillatory', 'damped'), 'upper right') Adding the commas after l1 and l4 unpack the sequence returned by plot, so l1 and l4 are now Line2D instances, not a sequence of lines. This whole business of return values being objects or sequences of objects is obscured by the fact that 'set' will operate on either, which is true for matlab, BTW. JDH |