Skip to content

Matplotlib hatch color broken #8076

@2sn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions