Skip to content

Matplotlib hatch color broken #8076

Closed
Closed

Description

@2sn

This may have some similarities with #7992, but seems not identical to other bug reports I found.

Bug report

Bug summary

  • It is no longer possible to set the color of hatching in patches. This still worked in 1.5.3-.
  • In particular, it affects PathPatch for me, but seems a more general problem.

Code for reproduction

An example modified from http://matplotlib.org/users/path_tutorial.html is

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)
ax.add_patch(patch)
ax.set_xlim(-2,2)
ax.set_ylim(-2,2)
plt.show()

Actual outcome

green rectangle filled with black cross hatching on white background.

Expected outcome

green rectangle filled with (more dense) green cross hatching on white background.
(Matplotlib 1.5.3-)

Matplotlib version

Python 3.6.0
IPython 5.2.2
Matplotlib 2.0.0

You should add a unit test for this.

Other examples

Activity

  1. dstansby commented on Feb 15, 2017

    @dstansby
    Member

    Thanks for the easy to copy-and-paste example! Running it on our current 2.0.x branch, I get the image below; is that what you were expecting?
    figure_1

  2. 2sn commented on Feb 15, 2017

    @2sn
    Author

    Thank you for the very fast reply.

    Yes, this is what it should look like. The version you were using not yet the current version on PyPi that I can install using pip, I assume; is this current version on the devel branch from git?

  3. dstansby commented on Feb 15, 2017

    @dstansby
    Member

    Yep, that's right. The branch I used is the current bugfix branch for 2.0, so the bug will be fixed when 2.0.1 is released.

  4. added this to the milestone on Feb 15, 2017
  5. dopplershift commented on Feb 15, 2017

    @dopplershift
    Contributor

    I think this was fixed by #7976 .

  6. 2sn commented on Mar 26, 2017

    @2sn
    Author

    Is there any ETA when version 2.0.1 may be released?
    It seems there is many fixes that have run up ... you don't have to catch them all at once, it does not have to be perfect, it never will be, you can always release a version 2.0.2 to fix more issues, ...
    For most of my collaborators wanting to use my packages and don't want to compile their own matplotlib version from git, the only really easy solution around for now is to revert back to 1.6.3, which is not really what we want ...

  7. bastibl commented on Apr 11, 2017

    @bastibl

    The bugfix branch also seems to have some problems. While it draws the patch correctly (as above), legends still use black hatches (i.e. don't match the patch).

  8. dstansby commented on Apr 11, 2017

    @dstansby
    Member

    Would it be possible to open a new issue with a minimal example that demonstrates broken hatches on legends?

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

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions