Sunday 15 September 2013

colors - matplotlib: plot and get_color? -


Is it possible to get a list of colors used in the plot? Consider this example:

  line1 = ax1.plot (x1, y1) line2 = ax1.plot (x2, y2)   

How do I now Set color

  plt.setp (line1, 'color', 'red') plt.setp (line 2, 'color', 'red')   

But is there a way to know which color has been used? Plt.getp (line1, 'color') does not work and complains that

  attributeError: there is no attribute in the 'list' object 'get_color'   

OK, got an answer: Plot () returns a list of call lines, color is the right way to query

  print line 1 [0] .get_color ()    

No comments:

Post a Comment