From: Peter B. <bu...@gm...> - 2009-09-27 20:45:55
|
On Sun, Sep 27, 2009 at 9:31 PM, Jae-Joon Lee <lee...@gm...> wrote: >> Some feedback: If plotting a line2D as discrete points rather than a >> continuous line, you must use numpoints=2 for the legend picking to actually >> occur on the points. The alpha blending doesn't work on the legend symbols >> however. >> > > I tried numpoints=1,2,3 but all worked for me. Can someone else confirm this? I'm using windows and mpl 0.99.0: numpoints=2 or 3 work with numpoints=1 the pick does not occur on the symbol but where it would be with numpoints=2 > The alpha for legend symbols does not work since, inside legend, the > lines and symbols are drawn by different artists. > > Try something like below. > > > legline.set_alpha(1.0) > try: > legline._legmarker.set_alpha(1.0) > except AttributeError: > pass > > > >> Is there any other way, I can show in the legend whether the points of the >> series are visible or not ? >> >> I thought of changing the labels, but failed to get them to redraw. >> > > Legend.get_texts() method returns the list of Text instances. > > http://matplotlib.sourceforge.net/api/artist_api.html?highlight=legend#matplotlib.legend.Legend.get_texts > > You may modify the returned Text instances. > > -JJ > works great. > >> # plots: >> ax.plot(t, y1, 'ro', picker=5, label='lab1') >> ax.plot(t, y2, 'bo', picker=5, label='lab2') >> >> # legend >> leg = ax.legend(loc='upper left', numpoints=2, fancybox=True, shadow=True) >> lines, labels = ax.get_legend_handles_labels() >> >> # Enable picking on the legend lines >> leglines=leg.get_lines() >> for legline in leglines: legline.set_picker(5) |