That works perfectly. Thank you all so much!
Gökhan SEVER-2 wrote: > > On Fri, Sep 17, 2010 at 1:13 PM, musik <xi.xiaoxi...@gmail.com> wrote: > >> >> Is there a way to set the legend font color? I am plotting multiple sets >> of >> data using different colors. I basically want to set each legend font >> color >> the same as the corresponding data line color. Here is an example. >> >> x = arange(0,10,0.1) >> y1 = sin(x) >> y2 = cos(x) >> >> plot(x,y1,'r-',x,y2,'b--') >> >> I want the legend font for y1 to be in red and the legend font for y2 to >> be >> in blue. >> >> Can anybody help? Thanks. >> > > I initially read like Ted did :) Here is a simple demonstration of Ben's > explanation: > > x = np.arange(0,10,0.1) > y1 = np.sin(x) > y2 = np.cos(x) > fig = plt.figure() > ax = fig.add_subplot(111) > p1, = ax.plot(x, y1, label="y1") > p2, = ax.plot(x, y2, label="y2") > leg = ax.legend() > text1, text2 = leg.get_texts() > # this part can be turned into a loop depends on the number of text > objects > text1.set_color(p1.get_color()) > text2.set_color(p2.get_color()) > plt.show() > > > -- > Gökhan > > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing. > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- View this message in context: http://old.nabble.com/legend-font-color-tp29741260p29747823.html Sent from the matplotlib - users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users