[Matplotlib-users] Get color from legend for errorbar plots

Scott Lasley selasley at icloud.com
Wed May 22 17:43:17 EDT 2019

As Tom Caswell pointed out, you can use the legendHandles.  Something like this may do what you want

z  = plt.legend()
[lc.get_colors() for lc in z.legendHandles]


> On May 22, 2019, at 2:34 PM, Bruno Pagani <bruno.pagani at astrophysics.eu> wrote:
> Hi,
> I’ve stumbled upon this very exact issue, for which there is no posted
> answer:
> https://stackoverflow.com/questions/26573864/matplotlib-get-errorbar-color-from-legend
> Does anyone have an idea?
> Regards,
> Bruno

More information about the Matplotlib-users mailing list