|
From: Eric F. <ef...@ha...> - 2013-08-02 03:37:33
|
On 2013/08/01 4:23 PM, Drain, Theodore R (392P) wrote: > I have an application where the user can edit line colors and other attributes after the plot is drawn. The artists update just fine but the legend doesn't change. > >>From what I can see in the legend code, it doesn't seem like there is any mechanism in place for doing this. Does anyone have any ideas on the best way to implement something like this? > > Here is a simplified script to show the issue: > > import pylab as p > p.ion() > l = p.plot( [1,2,3], 'b', label="foo" ) > p.legend() > > raw_input( "press return..." ) > l[0].set_color( "green" ) > p.draw() > > Thanks, > Ted If you keep a reference to the Legend object, then you can call its get_lines() method to get a list of Line2D objects corresponding to the objects returned by plot(). You can use the set_color() method on them. Maybe this is enough if your application is simple enough. Eric |