Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43432c2

Browse files
author
Phil Elson
committed
Docstrings & updated example.
1 parent 6e2061a commit 43432c2

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

examples/pylab_examples/contourf_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
CS3 = contourf(X, Y, Z, levels,
6666
colors = ('r', 'g', 'b'),
6767
origin=origin,
68-
extend='both')
68+
extend='both', hatch=['/', '\\'])
6969
# Our data range extends outside the range of levels; make
7070
# data below the lowest contour level yellow, and above the
7171
# highest level cyan:

lib/matplotlib/contour.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ def __init__(self, ax, *args, **kwargs):
731731
self.linewidths = kwargs.get('linewidths', None)
732732
self.linestyles = kwargs.get('linestyles', None)
733733

734-
self.hatch = kwargs.get('hatch', [None])
734+
self.hatches = kwargs.get('hatches', [None])
735735

736736
self.alpha = kwargs.get('alpha', None)
737737
self.origin = kwargs.get('origin', None)
@@ -911,11 +911,11 @@ def changed(self):
911911
tcolors = [ (tuple(rgba),) for rgba in
912912
self.to_rgba(self.cvalues, alpha=self.alpha)]
913913
self.tcolors = tcolors
914-
thatches = self.hatch * len(tcolors)
915-
self.thatches = thatches
916-
for color, hatch, collection in zip(tcolors, thatches, self.collections):
914+
hatches = self.hatches * len(tcolors)
915+
for color, hatch, collection in zip(tcolors, hatches, self.collections):
917916
if self.filled:
918917
collection.set_facecolor(color)
918+
# update the collection's hatch (may be None)
919919
collection.set_hatch(hatch)
920920
else:
921921
collection.set_color(color)
@@ -1486,6 +1486,10 @@ def _initialize_x_y(self, z):
14861486
points. This may never actually be advantageous, so this option may
14871487
be removed. Chunking introduces artifacts at the chunk boundaries
14881488
unless *antialiased* is *False*.
1489+
1490+
*hatches*:
1491+
A list of cross hatch patterns to use on the filled areas.
1492+
If None, no hatching will be added to the contour.
14891493
14901494
Note: contourf fills intervals that are closed at the top; that
14911495
is, for boundaries *z1* and *z2*, the filled region is::

0 commit comments

Comments
 (0)