Skip to content

wrong hatch color in legend #8463

Closed
Closed

Description

@bastibl

Follow-up of #8076.

Bug report

Bug summary

  • the hatch color in the legend doesn't match the color in the figure

Code for reproduction

  • A minimum code snippet required to reproduce the bug, also minimizing the number of dependencies required
import matplotlib.pyplot as plt
from matplotlib.path import Path
import matplotlib.patches as patches

verts = [
    (0., 0.), # left, bottom
    (0., 1.), # left, top
    (1., 1.), # right, top
    (1., 0.), # right, bottom
    (0., 0.), # ignored
    ]

codes = [Path.MOVETO,
         Path.LINETO,
         Path.LINETO,
         Path.LINETO,
         Path.CLOSEPOLY,
         ]

path = Path(verts, codes)

fig = plt.figure()
ax = fig.add_subplot(111)
patch = patches.PathPatch(path, color='green', fill=False, hatch='xx', lw=2, label='foo')
ax.add_patch(patch)
ax.set_xlim(-.5,1.5)
ax.set_ylim(-.5,1.5)
ax.legend(handlelength=10, handleheight=10)
plt.show()

Actual outcome

  • The legend uses a black hatch color

Expected outcome

  • The hatch color in the legend matches the hatch color in the figure.

Matplotlib version
Current v2.0.x branch (matplotlib-2.0.0+160.ge9ab1cf)

  • Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)
    Python 2.7, Ubuntu 16.04
  • How did you install Matplotlib and Python (pip, anaconda, from source ...)
    pip install git+https://github.com/matplotlib/matplotlib.git@v2.0.x#matplotlib

Activity

  1. dstansby commented on Apr 11, 2017

    @dstansby
    Member

    👍 Thanks for opening up a new issue! I can confirm this is a problem on current master. Since we want to release 2.0.1 soon (as far as I know) I'll mark as 2.0.x but not release critical.

  2. added this to the milestone on Apr 11, 2017
  3. tacaswell commented on Apr 18, 2017

    @tacaswell
    Member

    The problem is likely that the handler is failing to pull enough properties off the base artist.

  4. modified the milestones: , on May 3, 2017
  5. 2sn commented on May 4, 2017

    @2sn

    yes, this would be good to fix, it still makes plot with coloured hatching not usable in the otherwise great 2.0.x release.

  6. added a commit that references this issue on May 5, 2017
    122bf46
  7. modified the milestones: , on May 7, 2017
  8. 2sn commented on May 9, 2017

    @2sn

    This has now been fixed on master?

  9. WeatherGod commented on May 9, 2017

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions