Skip to content

Default color after setting alptha to Patch in legened #10574

Closed

Description

@KonradAdamczyk

Bug report

After setting alpha to legend Patch, the color of edited patch resets to default(blue).

Code for reproduction

"""
========
Barchart
========

A bar plot with errorbars and height labels on individual bars
"""
import matplotlib.pyplot as plt
import numpy as np

N = 5
men_means = (20, 35, 30, 35, 27)
men_std = (2, 3, 4, 1, 2)

ind = np.arange(N)  # the x locations for the groups
width = 0.35  # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(ind, men_means, width, color='r', yerr=men_std)

women_means = (25, 32, 34, 20, 25)
women_std = (3, 5, 2, 3, 3)
rects2 = ax.bar(ind + width, women_means, width, color='y', yerr=women_std)

# add some text for labels, title and axes ticks
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind + width / 2)
ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))

leg = ax.legend((rects1[0], rects2[0]), ('Men', 'Women'))

#this line causes bug - reset to default color(blue)
leg.get_patches()[0].set_alpha(0.854321)

plt.show()

Actual outcome
obraz
Expected outcome
obraz

Matplotlib version

  • Matplotlib version: 2.1.2
  • Python version: 2.7

Activity

  1. added a commit that references this issue on Feb 23, 2018
  2. anntzer commented on Nov 3, 2018

    @anntzer
    Contributor

    Looks like duplicate of #11702 and fixed by #11703.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions