Le mardi 27 janvier 2009 à 13:17 +0100, Marcin Krol a écrit :
> How do I set the attributes of Line2D instance? I have:
>
> origline = plt.plot(origlist)
> valine = plt.plot(valist)
> plt.xlim(0,256)
> valine.set_color('r')
> valine.set_linewidth(2)
>
> Traceback (most recent call last):
> AttributeError: 'list' object has no attribute 'set_color'
As mentioned in the traceback, valine is a list and not a Line2D
instance. In fact, the plt.plot function returns the list of the Line2D
instances added to the axes by the instruction. Even if you only plot
one curve.
As a solution, you may correct to
valine, = plt.plot(valist)
which unpack the list and extract the first item (the Line2D instance
you want) to valine.
--
Fabrice Silva <[email protected]>
LMA UPR CNRS 7051 - équipe S2M
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users